Skip to content

Instantly share code, notes, and snippets.

@benhosmer
Created March 17, 2014 11:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhosmer/9597511 to your computer and use it in GitHub Desktop.
Save benhosmer/9597511 to your computer and use it in GitHub Desktop.
Python script to convert a date to epoch time.
hiredate= '1981-06-03'
pattern = '%Y-%m-%d'
epoch = int(time.mktime(time.strptime(hiredate, pattern)))
print epoch
360388800
@dumptyd
Copy link

dumptyd commented Jul 19, 2017

that was helpful, thanks.

@dylancaponi
Copy link

For hiredate in UTC I used:
epoch = int(calendar.gmtime(time.strptime(hiredate, pattern)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment