Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Created May 3, 2013 05:47
Show Gist options
  • Select an option

  • Save iambibhas/5507408 to your computer and use it in GitHub Desktop.

Select an option

Save iambibhas/5507408 to your computer and use it in GitHub Desktop.
Get Unix timestamp from Python datetime object
from datetime import datetime
def get_timestamp_from_datetime(dt):
UNIX_EPOCH = datetime(1970, 1, 1, 0, 0, 0, 0)
delta = dt - UNIX_EPOCH
seconds = delta.total_seconds()
return seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment