Indradhanush Gupta
Indradhanush Gupta

Reputation: 4237

How to convert the time entered in django admin into utc?

There are a lot of questions here on SO to make Django-Admin time aware and all related stuff. But I couldn't get help from the existing ones. So I am asking a new one with a slightly different intent.

I want that when a user enters some data via the admin specifically when he is entering the date and time he is obviously entering it in his local time, that is the system time. I want that the admin should convert it into UTC before storing it in the DB. How can this be done?

Upvotes: 1

Views: 380

Answers (1)

Ranbir Singh
Ranbir Singh

Reputation: 203

If running in a Windows environment this must be set to the same as your system time zone.

TIME_ZONE = 'America/Los_Angeles'

Define it like this in your settings.py And replace the time zone according to you .

Upvotes: 2

Related Questions