I have a Date object and want to easily convert it to DateTime object, setting the time to an arbitrary value (e.g. 12:00:00).
I know it is possible taking the string and fiddleing with strptime and strftime.
I am curious if there is a easier, direct way to do that.
It can be done using datetime.combine(date, time), like suggested in: https://stackoverflow.com/a/1937636/3199774
from datetime import date
from datetime import datetime
d = date.today()
datetime.combine(d, datetime.min.time())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With