Created
June 27, 2012 17:25
-
-
Save codemaniac/3005546 to your computer and use it in GitHub Desktop.
MySQL datetime to unix ticks in python
This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
import time | |
def datetime2unixticks(ts): | |
ts = ts.split()[0] | |
dt = datetime.strptime(ts, '%Y-%m-%d') | |
return int(time.mktime(dt.timetuple())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment