datetime and tzinfo

J

John Hunter

I am using the tzinfo classes from the datetime docs, eg UTC,
USTimeZone, and the instantiations Pacific, Central, Eastern, etc. I
would like to take a datetime instance in the UTC timezone and
construct the equivalent in another time zone.

Eg, if I am given dt1 in the example below, and the timezone Central

dt1 = datetime(2004, 9, 12, 14, 22, 24, tzinfo=UTC())

I would like to construct the datetime instance dt2

dt2 = datetime(2004, 9, 12, 9, 22, 24, tzinfo=Central)

which is the same time in a different timezone.
datetime.timedelta(0)

I've read through the docs at
http://www.python.org/doc/2.3.2/lib/datetime-tzinfo.html but none of
the methods looked just right.

Is there an easy/right way to do this?

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top