Created
November 22, 2022 23:44
-
-
Save filevich/eebd32a9a0b102cb20de2748fcba8a95 to your computer and use it in GitHub Desktop.
python time delta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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