Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Ce site disposera de fonctionnalités limitées pendant que nous effectuons des opérations de maintenance en vue de vous proposer un meilleur service. Si un article ne règle pas votre problème et que vous souhaitez poser une question, notre communauté d’assistance est prête à vous répondre via @FirefoxSupport sur Twitter, et /r/firefox sur Reddit.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

new Date().getTimezoneOffset() returns wrong time zone offset against Firefox ESR 52

  • 9 réponses
  • 7 ont ce problème
  • 1 vue
  • Dernière réponse par Sunny12345

more options

I tried to use "new Date().getTimezoneOffset()" in a javascript to return the timezone offset between the time zone on my PC and UTC time.

The time zone on my PC is UTC+8,

Javascript as below, referring to https://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript

var offset = new Date().getTimezoneOffset(); console.log(offset);

It returns -60 mins. This is wrong.

Could you please advise the cause and resolution if there is?

Regards,

Sunny

I tried to use "new Date().getTimezoneOffset()" in a javascript to return the timezone offset between the time zone on my PC and UTC time. The time zone on my PC is UTC+8, Javascript as below, referring to https://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript var offset = new Date().getTimezoneOffset(); console.log(offset); It returns -60 mins. This is wrong. Could you please advise the cause and resolution if there is? Regards, Sunny

Toutes les réponses (9)

more options

Additional info. I've tried: reinstall and ESR 45.x and change time zone several times. getTimezoneOffset() always returns -60mins.

more options

What does this code give?

  • new Date().toString();
more options

I'm in Pacific Time. Firefox 54 returns 420, which I believe means 7 hours. Since we are at -7 hours (year-round offset of -8 hours adjusted for DST), I'm not sure why 420 is a positive number.

Is your Firefox "sandboxed" in any way, such that it may not be directly reading the time from Windows 7?

more options

Thanks for the reply.

new. Date().toString() returns a result indicates the wrong time zone GMT+1, as below, "Thu Aug 03 2017 02:39:03 GMT+0100"

more options

Thanks and please fine below answer.

jscher2000 said

I'm in Pacific Time. Firefox 54 returns 420, which I believe means 7 hours. Since we are at -7 hours (year-round offset of -8 hours adjusted for DST), I'm not sure why 420 is a positive number. =>what is the time zone setting on your PC? UTC-7? Is your Firefox "sandboxed" in any way, such that it may not be directly reading the time from Windows 7? I reinstalled Firefox ESR many times and the issue persists, i did not change the browser settings. How can i know if the firefox is sandboxed or not?
more options

Please note that the browser in question is Firefox ESR.

Firefox non ESR has no such issue.

If you install the latest Firefox, you can easily reproduce the issue i believe.

Thanks.

more options

Sunny12345 said

Thanks and please fine below answer. jscher2000 said
I'm in Pacific Time. Firefox 54 returns 420, which I believe means 7 hours. Since we are at -7 hours (year-round offset of -8 hours adjusted for DST), I'm not sure why 420 is a positive number.

=>what is the time zone setting on your PC? UTC-7?

Time Zone is -8, with automatic adjustment for Daylight Savings Time. (Screenshot attached.)

Is your Firefox "sandboxed" in any way, such that it may not be directly reading the time from Windows 7?

I reinstalled Firefox ESR many times and the issue persists, i did not change the browser settings.

How can i know if the firefox is sandboxed or not?

I don't use ESR, sorry. Firefox could be sandboxed by security software or by a virtual machine program (e.g., VirtualBox). Probably you would notice other symptoms such as limitations on Firefox's ability to work with the hard drive or interact with other programs.

more options

This looks like UK time.

What Firefox locale do you have (about:config -> general.useragent.locale)?

more options

Thank you! the locale is set to locale. please refer to the attachment.