Reputation: 368
My time format is screwy, but it seemed workable, as a string with the following format:
'47:37:00'
I tried to set a variable where:
DT = '%H:%M:%S'
So I could find the difference between two times, but it's given me the following error:
ValueError: time data '47:37:00' does not match format '%H:%M:%S'
Is it possible there are more elements to my time stamps than I thought? Or that it's formatted in minutes/seconds/milliseconds? I can't seem to find documentation that would help me determine my time format so I could set DT and do arithmetic on it.
Upvotes: 0
Views: 406
Reputation: 11
You wrote "I can't seem to find documentation that would help me determine my time format so I could set DT and do arithmetic on it"
Try this: https://docs.python.org/3/library/datetime.html
Way down to the bottom.
And yes, when the %H is matched with 47, you get boom the error.
Upvotes: 1
Reputation: 84
It's because you set 47 to %H, that is not a proper value. Here is an example:
import datetime
dt = datetime.datetime.strptime('2016/07/28 12:37:00','%Y/%m/%d %H:%M:%S')
print dt
Output: 2016-07-28 12:37:00
Upvotes: 1