I'm having difficulty working with dates in Python and Javascript.
>>> d = date(2004, 01, 01) >>> d datetime.date(2004, 1, 1) >>> time.mktime(d.timetuple()) 1072944000.0
Then, in Javascript (data sent over Ajax):
>>> new Date(1072944000.0) Tue Jan 13 1970 02:02:24 GMT-0800 (PST) {}
I'm confused. Shouldn't the Javascript date be the same as the one that I entered in Python? What am I doing wrong?
Javascript's Date()
takes milliseconds as an argument. Python's uses seconds. You have to multiply by 1,000.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With