Skip to content

Instantly share code, notes, and snippets.

@filevich
Created November 22, 2022 23:44
Show Gist options
  • Save filevich/eebd32a9a0b102cb20de2748fcba8a95 to your computer and use it in GitHub Desktop.
Save filevich/eebd32a9a0b102cb20de2748fcba8a95 to your computer and use it in GitHub Desktop.
python time delta
from datetime import datetime, timedelta
tic = datetime.now()
# do domething
d = (datetime.now() - tic) / timedelta(hours=1)
fmt_dur = lambda d: "{}".format(d)[:-7]
fmt_dur(datetime.now() - tic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment