views:

56

answers:

1

Case 1

>>> datetime.__file__
'/usr/lib/python2.6/lib-dynload/datetime.so'
>>> print datetime.datetime.now()
2010-05-19 19:45:40.202634

Case 2

from django.db import models
import datetime
print datetime.__file__
print "--------------------------", datetime.datetime.now()

-----------Result--------

Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Validating models...
/usr/lib/python2.6/lib-dynload/datetime.so
-------------------------- 2010-05-19 09:16:43.987508
0 errors found
+3  A: 

As Mark pointed it looks like time zone difference for Japan:

>>> from dateutil import tz
>>> from datetime import datetime
>>> utc_time = datetime(2010, 5, 19, 9, 16, 43, tzinfo=tz.tzutc())
>>> jst_time = utc_time.astimezone(tz.gettz('Japan'))
>>> print utc_time
2010-05-19 09:16:43+00:00
>>> print jst_time
2010-05-19 18:16:43+09:00

Standard datetime module handle naive time only, you can add a support of time zones with dateutil (especially dateutil.tz.tzlocal() constructor).

Denis Otkidach
you're right internally django was keeping tzinfo from settings.Time_Zone, I set to Asia/Calcutta and it worked well !
Tumbleweed