[Tutor] How does datetime.now() get timezone?

Christopher Arndt chris.arndt at web.de
Sun Mar 4 23:11:07 CET 2007


Hi all,

this is maybe more of a Linux question or about how Python plays together with
the OS:

I have a virtual server on which I installed Ubuntu Dapper LTS with a minimal
install plus the things I needed. If I do

from datetime import datetime
t = datetime.now()

there, 't' is a naive datetme object, i.e. t.tzinfo is None.

If I do the same on my developing machine, which has also Ubuntu Dapper, I get
a timezone-aware datatime object.

What do I have to do to set the timezone so that Python can recognize it? I
already installed the 'locales' package, ran 'tzconfig' and installed
timezoneconf and ran that, but to no avail.

Chris


More information about the Tutor mailing list