1

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?

1 Answer 1

6

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 [email protected]
Wed Sep  7 02:00:00 CEST 2005
$ date [email protected] -u
Wed Sep  7 00:00:00 UTC 2005
$ date [email protected] -u -Ins
2005-09-07T00:00:00,000000000+0000
$ date [email protected] -u "+'%-dth %b %Y"
'7th Sep 2005

Inversely, you could use something like:

$ date --date="7 Sep 2005" -u "+%s%3N"
1126051200000
7
  • Seconds, not milliseconds. Sep 11, 2012 at 0:41
  • Ooops, how right you are
    – EBGreen
    Sep 11, 2012 at 13:54
  • No, they are most certainly milliseconds.
    – Eroen
    Sep 11, 2012 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, 2012 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, 2012 at 14:25

You must log in to answer this question.