Skip to content

Instantly share code, notes, and snippets.

@richard-to
Created June 21, 2014 08:32
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 richard-to/a927e402631a089753d1 to your computer and use it in GitHub Desktop.
Save richard-to/a927e402631a089753d1 to your computer and use it in GitHub Desktop.
def datetime_to_timestamp(date, date_format):
"""
Converts date/time string to unix timestamp. Note that
the date/time string will interpreted using the local
timezone on your system.
The resulting unix timestamp will be in GMT time.
"""
dt = datetime.strptime(date, date_format)
return int(time.mktime(dt.timetuple()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment