Created
July 1, 2015 18:10
-
-
Save carlosm3011/697c4c34e4610be22f7f to your computer and use it in GitHub Desktop.
Convert MongoDB Date() to Unix TS in Python
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
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