UnixTime

UnixTime[]

gives the total number of seconds since the beginning of January 1, 1970, in the GMT time zone.

UnixTime[{y,m,d,h,m,s}]

gives the Unix time specification corresponding to a date list.

UnixTime[date]

gives the Unix time specification corresponding to a DateObject.

UnixTime["string"]

gives the Unix time specification corresponding to a date string.

UnixTime[{"string",{"e1","e2",}}]

takes the date string to contain the elements "ei".

Details

  • UnixTime[] returns the number of seconds that have elapsed since {1970, 1, 1, 0, 0, 0.} Greenwich Mean Time (GMT), not counting leap seconds.
  • UnixTime[time] assumes that the given time is in $TimeZone, unless it is a DateObject or TimeObject with an explicit TimeZone option value.
  • UnixTime[] returns the nearest whole second, down to a granularity of $TimeUnit seconds.
  • Shorter lists can be used in 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.

Examples

open allclose all

Basic Examples  (3)

Unix time in seconds since January 1, 1970:

In[1]:=
Click for copyable input
Out[1]=

Convert from a date object to Unix time:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Convert from a date string to Unix time:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Scope  (6)

Properties & Relations  (2)

See Also

FromUnixTime  AbsoluteTime  DateList  DateString  DateObject  JulianDate  FromJulianDate  DateValue  Now  SessionTime  TimeUsed  Clock  AbsoluteTiming  Timing  $TimeZone  $TimeUnit  FileDate

Tutorials

Introduced in 2015
(10.1)