datetimes, tzinfo and gmtime epoch

J

John Hunter

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top