Sometimes, we want to fix date parsing in JavaScript is different between Safari and Chrome.
In this article, we’ll look at how to fix date parsing in JavaScript is different between Safari and Chrome.
How to fix date parsing in JavaScript is different between Safari and Chrome?
To fix date parsing in JavaScript is different between Safari and Chrome, we should make sure the date string is in the right format.
For instance, we write
const c = new Date("2022-02-06T20:00:00.000+04:00");
console.log(c);
to create a new Date
object with a date string in a format that can be pared by both browsers.
We have '+04:00'
for the time zone offset which can be parsed correctly by both browsers.
Conclusion
To fix date parsing in JavaScript is different between Safari and Chrome, we should make sure the date string is in the right format.