Home >Web Front-end >JS Tutorial >Why Does Chrome 67 Report a Different Timezone Offset for Dates Before 1900?
Browsers, Time Zones, and Chrome 67: Navigating Historic Timezone Changes
In the context of time zones and browser behavior, a recent change in Chrome 67 has raised concerns among developers. Upon updating to version 67, some users have encountered timezone offset discrepancies compared to previous browser versions and other browsers.
Problem Statement
The main issue lies in handling dates before 1970, specifically the timezone offset for the Europe/Moscow timezone. In earlier Chrome versions, the offset was consistently reported as 03:00. However, Chrome 67 now returns 02:30 for dates prior to 1900.
Explanation
To understand this change, it's crucial to refer to the IANA time zone database, which provides reference data for browser time zone handling. According to this database, the Europe/Moscow timezone did indeed have an offset of 02:30:17 in 1900. Chrome appears to be rounding this offset down to 02:30, resulting in the observed behavior.
Implications and Considerations
While it may seem like a minor adjustment, this change can have significant implications for code that depends on accurate historical timezone data. To address this issue, it's recommended to avoid using timezone information for dates prior to 1970. The IANA theory file explicitly acknowledges the challenges of providing reliable data for these early periods.
Possible Cause of the Change
It's worth speculating why this change emerged specifically in Chrome 67. One possible explanation is that Chrome may have started using the IANA time zone data directly, as opposed to relying on the time zone data provided by the operating system. This would explain the deviation from previous Chrome versions, which could have been using the OS data.
Conclusion
Understanding the underlying mechanisms behind timezone handling in browsers is key to avoiding unexpected behaviors. By considering the data sources and the nuances of historical timezone transitions, developers can adapt their code to the latest browser changes and ensure consistent and reliable time zone handling. It's equally important to consider the limitations and accuracy of data available for dates prior to 1970.
The above is the detailed content of Why Does Chrome 67 Report a Different Timezone Offset for Dates Before 1900?. For more information, please follow other related articles on the PHP Chinese website!