I want to parse a string date time to a JavaScript Date object.
I'm wondering why using +Number in the string gives me different result from using (TimeZome)
Example:
let a = new Date('Nov 01, 2022 09:00:00 +0900')
let b = new Date('2022-11-01T09:00:00.000+09:00')
let c = new Date('01 Nov 2022 09:00:00 (JST)')
let d = new Date('Nov 01, 2022 09:00:00 (JST)')
console.log(`${a.getTime()} ${a.toISOString()} ${a.toLocaleString('en-us', { timeZone: 'JST' })}`);
console.log(`${b.getTime()} ${b.toISOString()} ${b.toLocaleString('en-us', { timeZone: 'JST' })}`);
console.log(`${c.getTime()} ${c.toISOString()} ${c.toLocaleString('en-us', { timeZone: 'JST' })}`);
console.log(`${d.getTime()} ${d.toISOString()} ${d.toLocaleString('en-us', { timeZone: 'JST' })}`);
the result is
"1667260800000 2022-11-01T00:00:00.000Z 11/1/2022, 9:00:00 AM"
"1667260800000 2022-11-01T00:00:00.000Z 11/1/2022, 9:00:00 AM"
"1667318400000 2022-11-01T16:00:00.000Z 11/2/2022, 1:00:00 AM"
"1667318400000 2022-11-01T16:00:00.000Z 11/2/2022, 1:00:00 AM"
it looks like using (JST) does not generate the correct result!
Note: I get the same result when I use Date.parse