Time Zone application after strptime?

J

Jim Carroll

It's taken me a couple of hours to give up on strptime with %Z for recognizing
time zones... but that still leaves me in the wrong zone:

def paypal_to_mysql_date(ppDate):
# a typical paypal date is 10:29:52 Feb 29, 2008 PST
date_parts = ppDate.split()
withouttz = " ".join(date_parts[:-1])

# eventually we need to apply the timezone
timezone = date_parts[-1]

dt = datetime.strptime(withouttz, "%H:%M:%S %b %d, %Y")
return dt.strftime("%Y-%m-%d %H:%M")


How can I use the "PST" (or any other time zone name) to adjust dt by the
correct number of hours to get it into UTC before storing in MySQL?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top