I understand how to convert a string to a datetime object, but what about a string that has a different time zone? for example “10/07/2011 04:22 CEST”
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
EST can mean two different timezones: European Summer Time, or Eastern Standard Time. So datetime strings such as
08/07/2011 04:22 ESTare ambiguous — there’s no sure-fire way to correctly convert such strings to a timezone-aware datetime.If you are willing to just make a stab at a possibly correct answer, then
you can generate a mapping between abbreviations like
ESTand timezone names, make a random choice among the valid timezones, andthen use that timezone to build a timezone-aware datetime: