I have weird behaviour using new Date(stringFormat) in js
Why is result of this:
var date = new Date('2020-03-01')
console.log(date.toISOString())
different than
var date = new Date(2020,2,1)
console.log(date.toISOString())
And this is what I get
2020-03-01T00:00:00.000Z
2020-02-29T23:00:00.000Z
I want to have always the first result. I want to understand why is there difference between these two, I see that it's something with timezones, but I'm providing same date in both cases but result is different. Is any of these overloading obsolete?
What is the reason for different interpreting of timezones by both methods? Can I assume that in every timezone and every browser from first method I will get first result?