Created
May 28, 2015 19:41
-
-
Save EFF/1b1c9bb875658d1334d0 to your computer and use it in GitHub Desktop.
python date conversion with js utc timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from date to js timestamp | |
from datetime import datetime | |
from calendar import timegm | |
python_date = datetime.now() | |
js_timestamp = timegm(python_date.timetuple()) * 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# date from js utc timestamp | |
from datetime import datetime | |
python_timestamp = 1432827134000 / 1000 #convert js timestamp into python timestamp | |
date = datetime.utcfromtimestamp(python_timestamp) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment