Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Time Zone application after strptime?

Thread Tools

Time Zone application after strptime?

Jim Carroll
Posts: n/a
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?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
time adjustment code according to time zone J.H.Kim C Programming 3 10-24-2011 04:19 PM
Time Zone in Windows Time Ryu ASP .Net 3 02-11-2009 08:46 PM
prevent a postback when moving web parts from zone to zone. =?Utf-8?B?VmluY2UgVmFyYWxsbw==?= ASP .Net 0 02-08-2006 12:20 AM
Zone Alarm or Zone Alarm Pro? Jones Computer Information 5 02-20-2004 07:29 PM
Multi-time zone date/time value? davout Java 3 10-16-2003 07:45 PM