Time Zone application after strptime?

Discussion in 'Python' started by Jim Carroll, Mar 7, 2008.

  1. Jim Carroll

    Jim Carroll Guest

    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!
     
    Jim Carroll, Mar 7, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryu

    Time Zone in Windows Time

    Ryu, Sep 15, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    18,476
    madamut
    Feb 11, 2009
  2. =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=

    prevent a postback when moving web parts from zone to zone.

    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=, Feb 8, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    599
    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=
    Feb 8, 2006
  3. kongkolvyu
    Replies:
    4
    Views:
    496
    Old Wolf
    Jan 4, 2006
  4. Greg Krohn
    Replies:
    1
    Views:
    996
    Denis Kasak
    Feb 17, 2009
  5. m_ahlenius

    problem with strptime and time zone

    m_ahlenius, Aug 24, 2010, in forum: Python
    Replies:
    5
    Views:
    2,161
    Alex Willmer
    Aug 25, 2010
Loading...

Share This Page