Created
January 8, 2014 16:48
-
-
Save shiumachi/8319962 to your computer and use it in GitHub Desktop.
datetime型をunixタイムスタンプに変換する
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
def convert_to_timestamp(dt): | |
""" input: DateTime object | |
output: unix timestamp | |
reference: http://stackoverflow.com/questions/2775864/python-datetime-to-unix-timestamp | |
""" | |
import calendar, datetime | |
return calendar.timegm(dt.utctimetuple()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment