Shiva Shiva - 2 months ago 15
Python Question

How to change my django server time

I want to save the present date in database, but my Django server starting 13 hours earlier than the present time. Due to this the time is also changing when I use the following:

datetime.datetime.now()


I am using Python 2.7.5 with Django 1.5.4.
How can I display my present system date with
django
..?

Answer

If your server date and time is wrong, try to fix that first. If they are correct, you can add a timezone value into your settings.py:

USE_TZ = True
TIME_ZONE = 'UTC'

Check http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid time zones.