You don't need to write Javascript in Python to convert the timestamps.
The following works in pure python.
Note:
- The JS Date format is the number of milliseconds since Jan 1,1970 UTC.
- Oddly enough, the python format for time.time() is the number of seconds since Jan 1, 1970 UTC.
This standard is sometimes called Unix time
First, for the milliseconds to seconds time conversion, you need to divide 1415988000000 by 1000, obtaining 1415988000
Then you can use the datetime library like this:
import datetime
d = datetime.datetime.fromtimestamp(1415988000)
print d
Obtaining:
2014-11-14 13:00:00
This print seems to have converted d to my TZ which is UTC-5.
So UTC time would be 18:00.
This explains the later time, 23:30, you receive in JS for the same stamp in IST or UTC+5:30
from datetime import datethenfoo = date(1415988000000)and for String representation use e.g.foo.ctime()foo = date.fromtimestamp(1415988000000 // 1000)(integer division)