Skip to content

Tag: datetime

Datetime Timezones from String

I am trying to figure out how to make a datetime object aware through using a variable. I grab the timezone of the user and pass it through a form to be used. I have tried both of the below methods and am not having much success This will then give me errors of TypeError: tzinfo argument must be None

python datetime strptime format

I have a datetime string like: I used strptime() function in datetime module to convert the string to datetime object. My datetime format is “%Y-%m-%dT%H:%M:%S.%f” When I parse this above string, the function raises ValueError because of missing millisecond part in the string. How can I have datet…