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!

Ovo će web mjesto raditi na ograničen način, dok obavljamo održavanje stranice. Ako neki članak ne riješi tvoj problem i ako želiš postaviti pitanje, naša zajednica za podršku spremna je pomoći na Twitteru @FirefoxSupport i na Redditu /r/firefox.

Pretraži podršku

Izbjegni prevare podrške. Nikad te nećemo tražiti da nas nazoveš, da nam pošalješ telefonski broj ili da podijeliš osobne podatke. Prijavi sumnjive radnje pomoću opcije „Prijavi zlouporabu”.

Saznaj više

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

  • 9 odgovora
  • 7 ima ovaj problem
  • 1 prikaz
  • Posljednji odgovor od 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

Svi odgovori (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.