Created
August 13, 2014 13:46
-
-
Save AllanLRH/b233623d75934468cec8 to your computer and use it in GitHub Desktop.
Calculate time difference from strings formattet HH:MM:SS, using datetime module.
This file contains 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 | |
def timeDifference(t0, t1): | |
FMT = '%H:%M:%S' | |
timeDelta = datetime.strptime(t1, FMT) - datetime.strptime(t0, FMT) | |
return timeDelta | |
if __name__ == '__main__': | |
t0 = '08:00:00' | |
t1 = '16:00:00' | |
delta_t = timeDifference(t0, t1) | |
print(delta_t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment