473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Time Zone application after strptime?

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!
Mar 7 '08 #1
0 923

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
10
by: Maksim Kasimov | last post by:
hi all, sorry if i'm reposting why time.strptime and time.localtime returns tuple with different DST (9 item of the tuple)? is there some of setting to fix the problem? Python 2.2.3 (#1, May...
2
by: Daniel Jung | last post by:
Hi 1088553069 => Wed Jun 30 01:51:22 2004 CEST I can do the time INT string substitution, but I want a set of "country codes", in order for my users to be able to pick their own preferences....
3
by: Ilja Booij | last post by:
Hi all, I have some trouble with the following: I'm getting a time string, in YYYY-MM-DD HH:mm:ss format, which I need to translate into a string with DD-Mon-YYYY HH:mm:ss +HHMM, where the...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
2
by: Joshua J. Kugler | last post by:
I am getting results like these with the time module: %S'))) 1173610800 %S'))) 1173610800 '2007-03-11 03:00:00' I know it probably has something to do with daylight savings, but how can I...
7
by: Steve | last post by:
Hi All I have a windows application written in VB.net 2005 The users have to select a State of Australia, which I use to check they have the correct windows time zone selected in control panel...
2
by: barronmo | last post by:
I'm trying to get the difference in dates using the time module rather than datetime because I need to use strptime() to convert a date and then find out how many weeks and days until that date. ...
0
by: Eric Wertman | last post by:
Sorry, my time zone is +4, not minus 4, which means that something else is causing my source data to be in the future. I still do need to understand where the time routines determine the time zone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.