Is it advisable to append Z to dates on the server side?
In summary Yes, it is recommended.
The correct handling of dates and date/times without a timezone has evolved over time, with variations in specifications and adherence by JavaScript engines.
Back in 2013 when this answer was first written, the ES5 spec stated that no timezone meant UTC:
The value of an absent time zone offset is “Z”.
However, this conflicted with ISO-8601 where the absence of a timezone indicator indicated local time. Some implementations stuck with ISO-8601 instead of ES5's definition.
In ES2015 (ES6), the specification was changed to align with ISO-8601:
If the time zone offset is absent, the date-time is interpreted as a local time.
Nevertheless, this change led to compatibility issues, especially with date-only formats like 2018-07-01
. Subsequently, in ES2016, the interpretation was adjusted again:
When the time zone offset is absent, date-only forms are interpreted as UTC time and date-time forms are interpreted as local time.
For example, new Date("2018-07-01")
is parsed as UTC, while new Date("2018-07-01T00")
is parsed as local time.
These rules have remained consistent in ES2017 and upcoming ES2018 versions; you can refer to the current editor's draft for more details.
You can test your browser's behavior using the provided code snippet.
Current browser support status as of September 2021:
- Modern Firefox, Chrome, and Safari browsers handle this correctly, including iOS browsers.
- Interestingly, IE11 also interprets dates accurately.
Past browser support status as of April 2018:
- IE11 handled dates correctly.
- Firefox had accurate date interpretations.
- Chrome 65 got it right on desktop and Android platforms.
- However, there were issues with Chrome 64 (iOS) and iOS Safari in parsing date/time forms incorrectly as UTC.
An open issue related to date parsing in V8 engine from Chrome 64 to 65 has been resolved, but specific details are not readily available.