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:

Convert from a date object to Unix time:

Convert from a date string to Unix time:

Scope  (6)

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

DateObject expressions can include their own TimeZone specification:

Separators are assumed if not specified:

Give explicit separators:

Date lists are converted to standard normalized form:

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

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

Properties & Relations  (2)

UnixTime converts a date specification into Unix time form:

FromUnixTime converts back into a DateObject expression:

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

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.

CMS

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_unixtime, organization={Wolfram Research}, title={UnixTime}, year={2015}, url={https://reference.wolfram.com/language/ref/UnixTime.html}, note=[Accessed: 22-December-2024 ]}