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. Advertisements

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,830
    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:
    775
    =?Utf-8?B?VmluY2UgVmFyYWxsbw==?=
    Feb 8, 2006
  3. davout
    Replies:
    3
    Views:
    723
    Roedy Green
    Oct 16, 2003
  4. kongkolvyu
    Replies:
    4
    Views:
    638
    Old Wolf
    Jan 4, 2006
  5. Greg Krohn
    Replies:
    1
    Views:
    1,161
    Denis Kasak
    Feb 17, 2009
  6. m_ahlenius

    problem with strptime and time zone

    m_ahlenius, Aug 24, 2010, in forum: Python
    Replies:
    5
    Views:
    2,439
    Alex Willmer
    Aug 25, 2010
  7. J.H.Kim

    time adjustment code according to time zone

    J.H.Kim, Oct 24, 2011, in forum: C Programming
    Replies:
    3
    Views:
    565
    Joel C. Salomon
    Oct 24, 2011
  8. Replies:
    9
    Views:
    502
    Michal Kleczek
    May 27, 2013
Loading...