Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been given some data to create some chart graphics and the dates are in a format I don't recognise. If I knew the format name I could easily look them up but initial search has drawn a blank. Example below..

        [1126051200000, 29.9],  '7th Sep 2005
        [1126137600000, 71.5],  '8th Sep 2005
        [1126224000000, 106.4], '9th Sep 2005
        [1126483200000, 129.2], '12th Sep 2005
        [1126569600000, 144.0], '13th Sep 2005
        [1126656000000, 176.0]  '14th Sep 2005

I've added the dates I know as comments but what format are these dates in? Eg how is 1126051200000 = 7th Sep 2005?

I suspect the 00000 padding is time but not used?

Thank you

share|improve this question

1 Answer 1

up vote 6 down vote accepted

They are Unix Epoch millisecond date/time stamps. Here is one converter or you could always write your own. Basically it is the number of milliseconds since 1/1/1970 not counting leap seconds.

Assuming you have a UNIX shell handy, they can be converted to any format using the date tool with the argument --date=${epoch_time}, for example:

$ date --date=@1126051200.000
Wed Sep  7 02:00:00 CEST 2005
$ date --date=@1126051200.000 -u
Wed Sep  7 00:00:00 UTC 2005
$ date --date=@1126051200.000 -u -Ins
2005-09-07T00:00:00,000000000+0000
$ date --date=@1126051200.000 -u "+'%-dth %b %Y"
'7th Sep 2005

Inversely, you could use something like:

$ date --date="7 Sep 2005" -u "+%s%3N"
1126051200000
share|improve this answer
    
Seconds, not milliseconds. –  Ansgar Wiechers Sep 11 '12 at 0:41
    
Ooops, how right you are –  EBGreen Sep 11 '12 at 13:54
    
No, they are most certainly milliseconds. –  Eroen Sep 11 '12 at 13:57
1  
I think the confusion comes from the fact that the time stamps in the question are Epoch milliseconds while the standard definition of Epoch Time is seconds. –  EBGreen Sep 11 '12 at 14:11
    
I agree, while adding that the epoch timestamp is often accompanied by a us or ns timestamp in the same struct or similar. I think the first version of the answer fits the question better (as in not wrong), though. Sorry about going overboard with examples, I didn't mean to, but I'm done now. –  Eroen Sep 11 '12 at 14:25

Your Answer

 
discard

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.