Skip to content

Instantly share code, notes, and snippets.

@mnguyenngo
Created October 8, 2018 22:34
Show Gist options
  • Save mnguyenngo/7b28b99e96b7bcf9ea3f29eb3ae85177 to your computer and use it in GitHub Desktop.
Save mnguyenngo/7b28b99e96b7bcf9ea3f29eb3ae85177 to your computer and use it in GitHub Desktop.
Working with time in Python
import datetime
import time
# get current date in format yymmdd; useful for naming files
today = datetime.date.today().strftime("%y%m%d")
# get current unix time in seconds as integer
now = int(time.time())
# get time at midnight for current day in seconds as integer
midnight = int(datetime.date.today().strftime("%s"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment