diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 871b96cfd4..b41c0cd505 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -18,8 +18,9 @@ var DateTimeShortcuts = { timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch timezoneOffset: 0, init: function() { - if (window.__admin_utc_offset__ !== undefined) { - var serverOffset = window.__admin_utc_offset__; + var body = document.getElementsByTagName('body')[0]; + var serverOffset = body.getAttribute('data-admin-utc-offset'); + if (serverOffset !== undefined) { var localOffset = new Date().getTimezoneOffset() * -60; DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; } @@ -39,8 +40,9 @@ var DateTimeShortcuts = { }, // Return the current time while accounting for the server timezone. now: function() { - if (window.__admin_utc_offset__ !== undefined) { - var serverOffset = window.__admin_utc_offset__; + var body = document.getElementsByTagName('body')[0]; + var serverOffset = body.getAttribute('data-admin-utc-offset'); + if (serverOffset !== undefined) { var localNow = new Date(); var localOffset = localNow.getTimezoneOffset() * -60; localNow.setTime(localNow.getTime() + 1000 * (serverOffset - localOffset)); diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index 77fdf5bb2f..fa6ee41b08 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -6,13 +6,13 @@ {% block extrastyle %}{% endblock %} {% if LANGUAGE_BIDI %}{% endif %} - {% block extrahead %}{% endblock %} {% block blockbots %}{% endblock %} {% load i18n %} -
+