datetimes, tzinfo and gmtime epoch

Discussion in 'Python' started by John Hunter, Apr 16, 2004.

  1. John Hunter

    John Hunter Guest

    I have a python2.3 datetime instance and a tzinfo instance (eg Eastern
    from the python library reference).

    What is the best way to convert that datetime instance to seconds
    since the epoch, gmtime?


    s1 = '2-Apr-04' # before dst
    s2 = '5-Apr-04' # after dst

    y,month,d,h,m,s,wd,jd,ds = time.strptime(s1, '%d-%b-%y')
    dt1 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)

    y,month,d,h,m,s,wd,jd,ds = time.strptime(s2, '%d-%b-%y')
    dt2 = datetime.datetime(y,month,d,h,m,s,tzinfo=Eastern)

    print dt1, Eastern.utcoffset(dt1)
    print dt2, Eastern.utcoffset(dt2)


    But I'm not sure how to convert this to epoch gmtime ....

    Thanks,
    John Hunter
     
    John Hunter, Apr 16, 2004
    #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. John Hunter

    datetime and tzinfo

    John Hunter, Sep 16, 2004, in forum: Python
    Replies:
    0
    Views:
    305
    John Hunter
    Sep 16, 2004
  2. Tino Lange
    Replies:
    1
    Views:
    459
    Lawrence D'Oliveiro
    Apr 3, 2006
  3. Cong Ma
    Replies:
    0
    Views:
    456
    Cong Ma
    Dec 8, 2008
  4. Cong Ma
    Replies:
    0
    Views:
    419
    Cong Ma
    Dec 9, 2008
  5. Michael Torrie
    Replies:
    0
    Views:
    405
    Michael Torrie
    Mar 12, 2010
Loading...

Share This Page