I have:
JavaScript
x
2
1
test_date = "2017-07-20-10-30"
2
and then use:
JavaScript
1
2
1
day = datetime.strptime(test_date[11:], "%H-%M")
2
which gives me
JavaScript
1
2
1
1900-01-01 10:30:00
2
How do I just get: 10:30:00
as type datetime.time
?
Advertisement
Answer
You can use the strftime
method of the datetime
object like this:
JavaScript
1
2
1
day.strftime('%H:%M')
2
More information here: https://docs.python.org/2/library/datetime.html#strftime-strptime-behavior
Ok, I misunderstood. Use day.time()
to get a time
object.