Skip to content

Instantly share code, notes, and snippets.

@carlosm3011
Created July 1, 2015 18:10
Show Gist options
  • Save carlosm3011/697c4c34e4610be22f7f to your computer and use it in GitHub Desktop.
Save carlosm3011/697c4c34e4610be22f7f to your computer and use it in GitHub Desktop.
Convert MongoDB Date() to Unix TS in Python
import datetime
import time
a="Date(2015,6,0,23,58,0)"
b=a[5:-1]
c=[int(x) for x in b.split(",")]
d=datetime.datetime(c[0],c[1]+1,c[2]+1,c[3],c[4],c[5])
timestamp = time.mktime(d.timetuple())
print d
print timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment