New date question

Why does this give me the day before, and how do I change it, to get my time zone? let test = new Date("2023-05-30"); console.log(test); Returns Mon May 29 2023 20:00:00 GMT-0400 (Eastern Daylight Time).
1 Reply
Joao
Joao2y ago
It seems that when you provide a string (maybe even some other argument) it will apply your timezone. You seem to be on GMT-4 and the date without any time reference uses midnight or 00:00, which -4 hours would be 20:00 of the day before. You can be more specific about the time you want to represent following the ISO 8601 format which is to say supported by Date.parse() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date#parameters https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse For example: new Date('2023-05-30T00:00:00.000')
Want results from more Discord servers?
Add your server