diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 28de479763..9bad0f54cb 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -28,8 +28,7 @@ timezoneWarningClass: 'timezonewarning', // class of the warning for timezone mismatch timezoneOffset: 0, init: function() { - const body = document.getElementsByTagName('body')[0]; - const serverOffset = body.dataset.adminUtcOffset; + const serverOffset = document.body.dataset.adminUtcOffset; if (serverOffset) { const localOffset = new Date().getTimezoneOffset() * -60; DateTimeShortcuts.timezoneOffset = localOffset - serverOffset; @@ -48,8 +47,7 @@ }, // Return the current time while accounting for the server timezone. now: function() { - const body = document.getElementsByTagName('body')[0]; - const serverOffset = body.dataset.adminUtcOffset; + const serverOffset = document.body.dataset.adminUtcOffset; if (serverOffset) { const localNow = new Date(); const localOffset = localNow.getTimezoneOffset() * -60;