0

I have a time string defined as below:

default = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

I would like to replace the time portion alone with my defined time say 9:00:00

How would I be able accomplish this with datatime?

  • related: https://stackoverflow.com/questions/12468823/python-datetime-setting-fixed-hour-and-minute-after-using-strptime-to-get-day – FObersteiner Jul 01 '20 at 17:36

1 Answers1

0

Using Replace:

datetime.datetime.now().replace(hour=23, minute=30).strftime('%Y-%m-%d %H:%M')