WOLFRAM

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)Summary of the most common use cases

Unix time in seconds since January 1, 1970:

Out[1]=1

Convert from a date object to Unix time:

Out[1]=1
Out[2]=2

Convert from a date string to Unix time:

Out[1]=1
Out[2]=2

Scope  (6)Survey of the scope of standard use cases

Inputs are assumed to be in $TimeZone. Block can be used to specify a different input time zone:

Out[1]=1
Out[2]=2
Out[3]=3

DateObject expressions can include their own TimeZone specification:

Out[1]=1
Out[2]=2

Separators are assumed if not specified:

Out[1]=1

Give explicit separators:

Out[2]=2

Date lists are converted to standard normalized form:

Out[1]=1
Out[2]=2

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

Out[1]=1
Out[2]=2

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

Out[1]=1

Properties & Relations  (2)Properties of the function, and connections to other functions

UnixTime converts a date specification into Unix time form:

Out[1]=1

FromUnixTime converts back into a DateObject expression:

Out[2]=2

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

Out[1]=1
Wolfram Research (2015), UnixTime, Wolfram Language function, https://reference.wolfram.com/language/ref/UnixTime.html.
Wolfram Research (2015), UnixTime, Wolfram Language function, https://reference.wolfram.com/language/ref/UnixTime.html.

Text

Wolfram Research (2015), UnixTime, Wolfram Language function, https://reference.wolfram.com/language/ref/UnixTime.html.

Wolfram Research (2015), UnixTime, Wolfram Language function, https://reference.wolfram.com/language/ref/UnixTime.html.

CMS

Wolfram Language. 2015. "UnixTime." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UnixTime.html.

Wolfram Language. 2015. "UnixTime." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UnixTime.html.

APA

Wolfram Language. (2015). UnixTime. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnixTime.html

Wolfram Language. (2015). UnixTime. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UnixTime.html

BibTeX

@misc{reference.wolfram_2025_unixtime, author="Wolfram Research", title="{UnixTime}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/UnixTime.html}", note=[Accessed: 26-March-2025 ]}

@misc{reference.wolfram_2025_unixtime, author="Wolfram Research", title="{UnixTime}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/UnixTime.html}", note=[Accessed: 26-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_unixtime, organization={Wolfram Research}, title={UnixTime}, year={2015}, url={https://reference.wolfram.com/language/ref/UnixTime.html}, note=[Accessed: 26-March-2025 ]}

@online{reference.wolfram_2025_unixtime, organization={Wolfram Research}, title={UnixTime}, year={2015}, url={https://reference.wolfram.com/language/ref/UnixTime.html}, note=[Accessed: 26-March-2025 ]}