By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,767 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,767 IT Pros & Developers. It's quick & easy.

datetimes, tzinfo and gmtime epoch

P: n/a

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

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.