When you create a new Date object that passes the dateString constructor to the constructor, it is parsed using Date.parse() . Now, quoting from the MDN documentation (emphasis mine):
Given the date string "March 7, 2014" (or "03/07/2014" ), parse() assumes a local time zone , but given an ISO format such as "2014-03-07" , it will accept the UTC time zone . Therefore, Date objects created using these strings will represent different points in time if the system is not installed with the local UTC time zone.
Therefore, since you specify the second line in ISO format, and your local time zone is UTC + 6 , you get a date that is six hours behind you, because it is calculated as UTC +0 . Actually:
Apr 07 1984 18:00:00 = Apr 08 1984 00:00:00 - 06:00:00
The mystery is solved!
Marco bonelli
source share