0

Javascript date conversion is taking the previous date.

new Date('2020-03-02')

In the same time zone if i use YYYY/MM/DD format it is working fine. (new Date('2020/03/02')) enter image description here

  • `YYYY-MM-DD` is always in UTC format. – Keith Feb 24 '20 at 13:07
  • Is there aby specific reason that taking previous time only when i am in Eastern time zone – TirupathiRao Feb 24 '20 at 13:09
  • 1
    Yes, if your 5 hours behind UTC, it will be the previous day if the time portion is before 5am. And just using the date will be before 5am. If you want to use UTC dates you could add the UTC offset.. eg. `'2020-03-02T00:00:00-0500'` – Keith Feb 24 '20 at 13:11

0 Answers0