469,964 Members | 1,645 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

datetimes, tzinfo and gmtime epoch

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

John Hunter

Jul 18 '05 #1
0 1387

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John Hunter | last post: by
2 posts views Thread by red floyd | last post: by
11 posts views Thread by red floyd | last post: by
1 post views Thread by Tino Lange | last post: by
11 posts views Thread by usenet | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.