搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Problem with date and timezones

  • 2 回覆
  • 1 有這個問題
  • 10 次檢視
  • 最近回覆由 Vampire_2008

more options

Hello! I have issue on JavaScript with Date and Timezones. I am c# developer. I have date from programm 24 July 2014. Internet Explorer 11 displays this date correct. But Firefox displays this date as 23 July 2014. I debug code and found this. My timezone is RTZ7 (Irkutsk) (current UTC+8). Internet Explorer saves date variable with timezone of this date (UTC+9) and when I format Date to string it saves timezone UTC+9. Firefox saves date variable without timezone in UTC format. 24 July 2014 00:00 - 9 hours = 23 July 2014 15:00. And when I format this Date to string I get 23 July 2014 23:00. Firefox add 8 hours to date, not 9 hours. In July 2014 my timezone was UTC+9. Why Firefox not save original timezone?

Hello! I have issue on JavaScript with Date and Timezones. I am c# developer. I have date from programm 24 July 2014. Internet Explorer 11 displays this date correct. But Firefox displays this date as 23 July 2014. I debug code and found this. My timezone is RTZ7 (Irkutsk) (current UTC+8). Internet Explorer saves date variable with timezone of this date (UTC+9) and when I format Date to string it saves timezone UTC+9. Firefox saves date variable without timezone in UTC format. 24 July 2014 00:00 - 9 hours = 23 July 2014 15:00. And when I format this Date to string I get 23 July 2014 23:00. Firefox add 8 hours to date, not 9 hours. In July 2014 my timezone was UTC+9. Why Firefox not save original timezone?

所有回覆 (2)

more options
more options

Variable Date I parse from MS Timestamp.

timestamp = new Date(parseInt(msMatch[1], 10));

Then I convert to custom format string with: G = timestamp.getHours(),//return 23 hours i = timestamp.getMinutes(), j = timestamp.getDate(), n = timestamp.getMonth() + 1, o = timestamp.getTimezoneOffset(),//return UTC+8 s = timestamp.getSeconds(), u = timestamp.getMilliseconds(), w = timestamp.getDay(), Y = timestamp.getFullYear(),