views:

28

answers:

2
new_thing = MyTable(last_updated=datetime.datetime.now())
new_thing.save()

>>>>select * from MyTable\G;
last_updated: 2010-04-01 05:26:21

However, in my Python console...this is what it says...

>>> print datetime.datetime.now()
2010-04-01 10:26:21.643041

So obviously it's off by 5 hours. By the way, the database uses "SYSTEM" as its time, so they should match perfectly.

mysql> SELECT current_time;
+--------------+
| current_time |
+--------------+
| 10:30:16     |
+--------------+
>>> print datetime.datetime.now()
2010-04-01 10:30:17.793040
+1  A: 

Difference is between your timezone and whatever is set in Django settings.py TIME_ZONE. By default it's 'America/Chicago'.

Łukasz
+1  A: 

I suspect that Django save the time in DB according to GMT and the ORM give it back to you according to your locale.

Tell use what does this code say :

print MyTable.objects.all().order_by("-last_updated")[0].get()
e-satis