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".
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 all close allBasic Examples (3)
Unix time in seconds since January 1, 1970:
UnixTime[]Convert from a date object to Unix time:
UnixTime[DateObject[{2014, 12, 18, 10}, "Hour", "Gregorian", -4.]]UnixTime[DateObject[{2007, 1, 1, 0, 0, 0.}, "Instant", "Gregorian", 0.]]Convert from a date string to Unix time:
DateString[]UnixTime[%]Scope (6)
Inputs are assumed to be in $TimeZone. Block can be used to specify a different input time zone:
$TimeZoneUnixTime["2006-12-1"]Block[{$TimeZone = 0}, UnixTime["2006-12-1"]]DateObject expressions can include their own 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"}}]]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"}}]]Properties & Relations (2)
UnixTime converts a date specification into Unix time form:
UnixTime[Now]FromUnixTime converts back into a 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}]]]Tech Notes
Related Guides
History
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_2026_unixtime, author="Wolfram Research", title="{UnixTime}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/UnixTime.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_unixtime, organization={Wolfram Research}, title={UnixTime}, year={2015}, url={https://reference.wolfram.com/language/ref/UnixTime.html}, note=[Accessed: 13-June-2026]}