Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have data that is timestamped with UNIX time, which is the number of seconds since January 1, 1970 UTC. Unfortunately, it seems that most of the date and time functions in Mathematica are based on the system's local time zone. How can I convert a UNIX timestamp to a DateList in UTC?

share|improve this question
DateList[] takes an absolute time as input. But M absolute time start in 1900 and not 1970. Hence take your Unix time, and add to it AbsoluteTime[{1970, 1, 1, 0, 0, 0}], which is 2208988800 seconds. Now your Unix list become M absolute time, then you can use DateList on it. Will this work for you? If you show some input will help. – Nasser Aug 26 '13 at 0:17

2 Answers 2

up vote 7 down vote accepted

Since Mathematica version 10.1 there is the function FromUnixTime that performs the conversion from a UNIX timestamp to a DateObject.


enter image description here

FromUnixTime[1427793986] // DateList

{2015, 3, 31, 11, 26, 26.}

FromUnixTime[0, TimeZone -> 0]

enter image description here

share|improve this answer
The associated Wolfram Blog post has additional background on this and other new date & time abilities (like ISO 8601 support). – duozmo Oct 16 at 21:45

The number of seconds between January 1, 1900 and January 1, 1970 can be given by AbsoluteTime[{1970, 1, 1, 2, 0, 0}]. There is also DateList which, if given a number, will calculate what the date would be if that was the number of seconds given by AbsoluteTime.

DateList[AbsoluteTime[], TimeZone -> 2]

{2013, 8, 26, 2, 28, 7.97767}

DateList[AbsoluteTime[{1970, 1, 1, 2, 0, 0}] + First@ReadList["!date +%s"]]

{2013, 8, 26, 2, 28, 7.}

The slight difference seems to be because the UNIX timestamp rounds downwards.

(First@ReadList["!date +%s"] only gives the current timestamp on UNIX systems. Everyone else will have to paste in their own timestamps to try it out. Also, I'm using my own time zone which is +2.)

share|improve this answer
Generalizing, the offset is AbsoluteTime[{1970, 1, 1, TimeZone[], 0, 0}]? I'm super confused! I asked about this as a new question here:… – dreeves Mar 23 at 3:03
@dreeves Yes, or $TimeZone (TimeZone[] appears to be undocumented.) – Pickett Mar 23 at 10:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.