Python Requires Chilkat v11.0.0+
Python
Read the sender’s Date in UTC and local time
See more Email Object Examples
Parse the Date header from an EML file, then print the same instant in UTC and the current computer’s local zone. Date is the time reported by the sender. For a relay timestamp, use a Received header.
Chilkat Python Downloads
import sys
import chilkat2
success = False
# Assumes Chilkat is unlocked. See Global Unlock Sample.
email = chilkat2.Email()
success = email.LoadEml("message.eml")
if (success != True):
print(email.LastErrorText)
sys.exit()
dateHeader = email.GetHeaderField("Date")
when = chilkat2.CkDateTime()
success = when.SetFromRfc822(dateHeader)
if (success != True):
print("Failed: when.SetFromRfc822.")
sys.exit()
print("Header: " + dateHeader)
print("UTC: " + when.GetAsTimestamp(False))
print("Local: " + when.GetAsTimestamp(True))