Skip to content
Advertisement

Convert datetime to time in python

I have:

JavaScript

and then use:

JavaScript

which gives me

JavaScript

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

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.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement