I am using exchangelib to process emails in python. When I execute the following code,Iget UTC datetime.How can I get the local date and time of the emails received as per the local timezone?
for email_message in outlook_inbox: #outlook_inbox is the object poining to my inbox
print(email_message .datetime_received)
Do you mean local timezone of where you are located, or local time of where the user is located?
You can get the former via
msg.datetime_received.localize(account.default_timezone)
The latter only really makes sense for calendar items where the local timezone has a semantic meaning. It's a bit more complicated (we should make an official method for this):