Skip to content

Instantly share code, notes, and snippets.

@EFF
Created May 28, 2015 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EFF/1b1c9bb875658d1334d0 to your computer and use it in GitHub Desktop.
Save EFF/1b1c9bb875658d1334d0 to your computer and use it in GitHub Desktop.
python date conversion with js utc timestamp
#from date to js timestamp
from datetime import datetime
from calendar import timegm
python_date = datetime.now()
js_timestamp = timegm(python_date.timetuple()) * 1000
# 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