I have a string like this:
'2021-07-24'
I want to change this to datetime type like this:
2021-07-24T00:00:00.000+09:00
How to replace str with datetime like that format?
I have a string like this:
'2021-07-24'
I want to change this to datetime type like this:
2021-07-24T00:00:00.000+09:00
How to replace str with datetime like that format?
You can try this:
from datetime import datetime, timezone, timedelta
dt_obj = datetime.fromisoformat('2021-07-24').replace(tzinfo=timezone(timedelta(hours=9))).isoformat()
print(dt_obj)
Output:
2021-07-24T00:00:00+09:00