If you execute this in console
new Date('2020-06-16')
you will get
Mon Jun 15 2020 20:00:00 GMT-0400 (Eastern Daylight Time)
Why is this?
If you execute this in console
new Date('2020-06-16')
you will get
Mon Jun 15 2020 20:00:00 GMT-0400 (Eastern Daylight Time)
Why is this?
new Date()
generates the unix timestamp for UTC (+0000 timezone), then the string display is giving you that timestamp in your local timezone. EST is a negative timezone, so UTC happens before midnight and it appears as if you are still in the day before.
new Date('2020-06-16')
Tue Jun 16 2020 01:00:00 GMT+0100 (British Summer Time)
You can add a timezone to your dates if you want to specify local midnight rather than global midnight.
new Date('2020-06-16:00:00:00-4000')
Wed Jun 17 2020 17:00:00 GMT+0100 (British Summer Time) {}