Skip to content

Instantly share code, notes, and snippets.

@traderbagel
Created August 20, 2020 09:01
Show Gist options
  • Save traderbagel/cbc020ac7861d6dacad084f7c15288d9 to your computer and use it in GitHub Desktop.
Save traderbagel/cbc020ac7861d6dacad084f7c15288d9 to your computer and use it in GitHub Desktop.
python datatime to timestamp and vice-versa
from datetime import datetime
ts = 1597809600
dt = datetime.fromtimestamp(ts)
# current date and time
now = datetime.now()
ts = datetime.timestamp(now)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment