Skip to content

Instantly share code, notes, and snippets.

@ruddra
Last active December 11, 2019 12:16
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 ruddra/0c6eaacd8ab31a6ec39d88893c049f5d to your computer and use it in GitHub Desktop.
Save ruddra/0c6eaacd8ab31a6ec39d88893c049f5d to your computer and use it in GitHub Desktop.
String to Epoch using Python
import datetime
def convert_to_epoch(date_string, format="%Y-%m-%dT%H:%M:%SZ"):
dt = datetime.datetime.strptime(date_string, format)
return int(str(dt.timestamp())[:-2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment