当サイトはユーザー体験を改善するためのメンテナンスを実施中に機能が制限される予定です。記事を読んでもあなたの問題が解決せず質問をしたい場合は、Twitter の @FirefoxSupport、Reddit の /r/firefox で、サポートコミュニティが皆さんを助けようと待機しています。

Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

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

  • 9 件の返信
  • 7 人がこの問題に困っています
  • 1 回表示
  • 最後の返信者: 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

すべての返信 (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.