This statement:
const date = new Date( '2022-05-04' );
produces the following value:
date = Tue May 03 2022 17:00:00 GMT-0700 (MST)
What's up with that?
How do I correct this?
TIA
This statement:
const date = new Date( '2022-05-04' );
produces the following value:
date = Tue May 03 2022 17:00:00 GMT-0700 (MST)
What's up with that?
How do I correct this?
TIA
The function gives the date according to your system's timezone. If you want UTC you need to mention it explicitly.
const date = new Date( '2022-05-04' ).toUTCString();
Similarly you can change to other timezones.
Adding the .toUTCString() method fixed it. Thanks!