1

Evening all,

When you click now on the Django admin DateTimeField picker widget, it fills in the current time with a little javascript.

However, my server is in UTC, and my client is in UTC+1 (British summer time, the most ironically named timezone).

So when I click now, I see 17:16 in the box. Which is not the correct time for now on the server, which is 16:16. So from my system's point of view, a model that is created now by the user, looks an hour old.

Is there a correct way to solve this?

0atman
  • 3,298
  • 4
  • 30
  • 46

2 Answers2

2

Can you store all the data in UTC and convert client side to the correct time for that timezone for display, and to UTC for storage?

timmow
  • 3,595
  • 2
  • 23
  • 22
  • Thanks Tim, we indeed store all dates as UTC (due to mysql limitations). However it is the nature of this client-side conversion that I was interested in. Anyone can throw together a fix (probably by overwriting the model's `save()` method and tweaking the django admin form, but I was hoping there might be a "right" way to do this, maybe even a Django way. – 0atman Apr 20 '13 at 16:33
0

The way I propose it might work is by using the server time, as served by the headers:

Date: fri, 19 apr 2013 16:16:00 gmt

However, that gets less correct the longer the page is open, so it's not a very good answer...

Community
  • 1
  • 1
0atman
  • 3,298
  • 4
  • 30
  • 46