I have a string in the str
format
PATTERN_OUT = "%H:%M"
date_time = (datetime.strftime(enddateandtime, PATTERN_OUT))
I need to convert it to datetime.time
. How can this be done?
I have a string in the str
format
PATTERN_OUT = "%H:%M"
date_time = (datetime.strftime(enddateandtime, PATTERN_OUT))
I need to convert it to datetime.time
. How can this be done?
You can utilize the fact that time string is \d\d:\d\d
.
Look at the following snippet.
from datetime import time
time_str = "10:01"
time(*map(int, time_str.split(':')))
Add exception handler if required.