({{, (RefLink[UnixTime, paclet:ref/UnixTime])[] 
gives the total number of seconds since the beginning of January 1, 1970, in the GMT time zone.}, {, (RefLink[UnixTime, paclet:ref/UnixTime])[{y,m,d,h,m,s}]
gives the Unix time specification corresponding to a date list.}, {, (RefLink[UnixTime, paclet:ref/UnixTime])[date]
gives the Unix time specification corresponding to a (RefLink[DateObject, paclet:ref/DateObject]).}, {, (RefLink[UnixTime, paclet:ref/UnixTime])["string"]
gives the Unix time specification corresponding to a date string.}, {, (RefLink[UnixTime, paclet:ref/UnixTime])[{"string",{"(Subscript[e, 1])","(Subscript[e, 2])",…}}]
takes the date string to contain the elements "(Subscript[e, i])".}})

OpenersNotesSection(Spacer1)Details

(RefLink[UnixTime, paclet:ref/UnixTime])[] returns the number of seconds that have elapsed since {1970, 1, 1, 0, 0, 0.} Greenwich Mean Time (GMT), not counting leap seconds.

(RefLink[UnixTime, paclet:ref/UnixTime])[time] assumes that the given time is in (RefLink[$TimeZone, paclet:ref/$TimeZone]), unless it is a (RefLink[DateObject, paclet:ref/DateObject]) or (RefLink[TimeObject, paclet:ref/TimeObject]) with an explicit (RefLink[TimeZone, paclet:ref/TimeZone]) option value.

(RefLink[UnixTime, paclet:ref/UnixTime])[] returns the nearest whole second, down to a granularity of (RefLink[$TimeUnit, paclet:ref/$TimeUnit]) seconds.

Shorter lists can be used in (RefLink[UnixTime, paclet:ref/UnixTime])[{y,m,…}]: {y} is equivalent to {y,1,1,0,0,0}, {y,m} to {y,m,1,0,0,0}, etc.

Values of m, d, h, m, s outside their normal ranges are appropriately reduced. Noninteger values of d, h, m, s can also be used.

OpenersPrimaryExamplesSection(Spacer1)Examples  (11)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Unix time in seconds since January 1, 1970:

UnixTime[]

Convert from a date object to Unix time:

UnixTime[(DateObject["Hour: ""Thu 18 Dec 2014 10 am""GMT"-4.`, DateObject[{2014,12,18,10},"Hour","Gregorian",-4.`]])]

UnixTime[(DateObject["Mon 1 Jan 2007 00:00:00""GMT", DateObject[{2007,1,1,0,0,0.`},"Instant","Gregorian",0.`]])]

Convert from a date string to Unix time:

DateString[]

UnixTime[%]

OpenersExampleSection1(Spacer1)Scope  (6)

Inputs are assumed to be in (RefLink[$TimeZone, paclet:ref/$TimeZone]). (RefLink[Block, paclet:ref/Block]) can be used to specify a different input time zone:

$TimeZone

UnixTime["2006-12-1"]

Block[{$TimeZone = 0},UnixTime["2006-12-1"]]

(RefLink[DateObject, paclet:ref/DateObject]) expressions can include their own (RefLink[TimeZone, paclet:ref/TimeZone]) specification:

UnixTime[DateObject[{2015,2,19,11,0,0},TimeZone->0]]

UnixTime[DateObject[{2015,2,19,11,0,0},TimeZone->-5]]

Separators are assumed if not specified:

Block[{$TimeZone=-5},UnixTime[{"2/23/2007",{"Month","Day","Year"}}]]

Give explicit separators:

Block[{$TimeZone=-5},UnixTime[{"2/23/2007",{"Month","/","Day","/","Year"}}]]

Date lists are converted to standard normalized form:

Block[{$TimeZone = 2},UnixTime[{2006,2,31}]]

Block[{$TimeZone = 2},UnixTime[{2006,3,3}]]

Day, hour, minute, and second values in input date lists can be noninteger:

Block[{$TimeZone=-7}, UnixTime[{2007,3,15.5}]]

Block[{$TimeZone=-7},UnixTime[{2007,3,15,12.3}]]

The current year is used if not specified in a string:

Block[{$TimeZone = 4},UnixTime[{"2/15",{"Month","Day"}}]]

OpenersExampleSection3(Spacer1)Properties & Relations  (2)

(RefLink[UnixTime, paclet:ref/UnixTime]) converts a date specification into Unix time form:

UnixTime[Now]

(RefLink[FromUnixTime, paclet:ref/FromUnixTime]) converts back into a (RefLink[DateObject, paclet:ref/DateObject]) expression:

FromUnixTime[%]

Compute the number of seconds between January 1, 1900, and January 1, 1970:

Block[{$TimeZone = 0},Abs[UnixTime[{1900,1,1,0,0,0}]]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FromUnixTime, paclet:ref/FromUnixTime])  ▪  (RefLink[AbsoluteTime, paclet:ref/AbsoluteTime])  ▪  (RefLink[DateList, paclet:ref/DateList])  ▪  (RefLink[DateString, paclet:ref/DateString])  ▪  (RefLink[DateObject, paclet:ref/DateObject])  ▪  (RefLink[JulianDate, paclet:ref/JulianDate])  ▪  (RefLink[FromJulianDate, paclet:ref/FromJulianDate])  ▪  (RefLink[DateValue, paclet:ref/DateValue])  ▪  (RefLink[Now, paclet:ref/Now])  ▪  (RefLink[SessionTime, paclet:ref/SessionTime])  ▪  (RefLink[TimeUsed, paclet:ref/TimeUsed])  ▪  (RefLink[Clock, paclet:ref/Clock])  ▪  (RefLink[AbsoluteTiming, paclet:ref/AbsoluteTiming])  ▪  (RefLink[Timing, paclet:ref/Timing])  ▪  (RefLink[$TimeZone, paclet:ref/$TimeZone])  ▪  (RefLink[$TimeUnit, paclet:ref/$TimeUnit])  ▪  (RefLink[FileDate, paclet:ref/FileDate])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Date and Time Functions, paclet:tutorial/DateAndTimeFunctions])}, {▪(RefLinkPlain[Global System Information, paclet:tutorial/GlobalSystemInformation])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}, {▪(RefLinkPlain[Date & Time, paclet:guide/DateAndTime])}})}})