What is the rough timestamp: 1267488000000

And how do I convert it to a datetime.datetime instance in python?

This is the exit from the New York State Senate API: http://open.nysenate.gov/legislation/ .

+5
source share
9 answers

Sounds like Unix time, but with milliseconds instead of seconds?

>>> import time
>>> time.gmtime(1267488000000 / 1000)
time.struct_time(tm_year=2010, tm_mon=3, tm_mday=2, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=61, tm_isdst=0)

March 2, 2010?

And if you want an object datetime:

>>> import datetime
>>> datetime.datetime.fromtimestamp(1267488000000 / 1000)
datetime.datetime(2010, 3, 1, 19, 0)

Note that it datetimeuses the local time zone, and time.struct_timeUTC.

+15
source

Maybe milliseconds?

>>> import time
>>> time.gmtime(1267488000000/1000)
time.struct_time(tm_year=2010, tm_mon=3, tm_mday=2, \
    tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=61, tm_isdst=0)
+5
source

:

import datetime
datetime.datetime.fromtimestamp(1267488000000/1000)
+4

( tousends ). :

datetime.datetime.fromtimestamp(timestamp / 1000)
+3

. , , 1 1970 .

+3

1267488000000 - . "Tue Mar 02 2010 08:00:00 GMT+0800 (WST)" ( , )

+2
source

Note that the Javascript Date object and Java Date class use milliseconds from January 1, 1970 GMT. Both languages ​​are commonly used in web services.

+2
source

This is almost certainly a timestamp (the number of milliseconds since an era). You want to date.fromtimestamp(timestamp)understand this.

+1
source

This is probably a Unix timestamp. See here for some time conversions in python.

+1
source

All Articles