#33810 closed Bug (worksforme)
Admin "now" time is incorrect
Reported by: | Michael | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 4.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The current time where I am is 00:25
In Javascript it prints:
> new Date() Tue Jun 28 2022 00:25:07 GMT+0200 (South Africa Standard Time)
On the linux server running Django (a different computer to my browser):
$ date Tue 28 Jun 2022 12:25:48 AM SAST
But in the Django admin if I click the now of a date/time widget it adds:
2022-06-27 17:26:23 Note: You are 7 hours ahead of server time.
It says I am 7 hours ahead, but my computer is set to SAST as well.
This is my timezone settings (using Django==4.0.1, with zoneinfo):
# SAST = South African Standard Time is GMT+2 USE_TZ = True TIME_ZONE = 'Africa/Johannesburg'
I see there was work on this issue about a decade ago. Not sure where the wonky "now" time is coming from.
Change History (6)
comment:1 by , 2 years ago
Description: | modified (diff) |
---|
follow-up: 3 comment:2 by , 2 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Type: | Uncategorized → Bug |
comment:3 by , 2 years ago
Replying to Mariusz Felisiak:
The admin's site operates in the server time and it works for me with
TIME_ZONE = 'Africa/Johannesburg'
. I don't think you've explained the issue in enough detail to confirm a bug in Django. Please reopen the ticket if you can debug your issue and provide details about why and where Django is at fault. If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.
As explained and checked the server time is SAST, and Django settings is set to SAST, and so is my computer SAST, but Django Admin is showing a 7hr timezone error. I am not asking for help, there is nothing else one can change, the admin site is auto generated.
comment:4 by , 2 years ago
Summary: | Admin "now" time very strange → Admin "now" time is incorrect |
---|
follow-up: 6 comment:5 by , 2 years ago
Resolution: | needsinfo → worksforme |
---|
This looks like a configuration error. As far as I can see everything is working as expected.
You are 7 hours ahead of server time.
The default TIME_ZONE
is 'America/Chicago'
, which is GMT-5. 'Africa/Johannesburg'
is (as you say) GMT+2, so there's your 7. Best guess is that your settings aren't applied as you think they are.
However, without more detail it's impossible to say if there's a deeper error.
If you can create a sample project that demonstrates an issue, then we can have a look, but short of that, there's nothing we can say.
comment:6 by , 2 years ago
Replying to Carlton Gibson:
This looks like a configuration error. As far as I can see everything is working as expected.
You are 7 hours ahead of server time.
The default
TIME_ZONE
is'America/Chicago'
, which is GMT-5.'Africa/Johannesburg'
is (as you say) GMT+2, so there's your 7. Best guess is that your settings aren't applied as you think they are.
However, without more detail it's impossible to say if there's a deeper error.
If you can create a sample project that demonstrates an issue, then we can have a look, but short of that, there's nothing we can say.
Thank for you that extra insight, I will see if I can isolate it and make a sample project.
It appears as though the setting is applied to me:
$ python manage.py shell Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from django.conf import settings >>> settings.TIME_ZONE 'Africa/Johannesburg'
I will try think of what else I can do.
The admin's site operates in the server time and it works for me with
TIME_ZONE = 'Africa/Johannesburg'
. I don't think you've explained the issue in enough detail to confirm a bug in Django. Please reopen the ticket if you can debug your issue and provide details about why and where Django is at fault. If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.