I have a very strange behavior in my web app. On one page, new Date()
parsing works fine while on other pages, it seems like I get a totally different behavior from the new Date()
parsing and it completely fails. I have verified that the Date object has not been overwritten extended or modified and I even tried using moment.js and I get the same results when it's converted to a Date
object. I have also verified the same behavior in both Chrome and Edge. Any suggestions?
Page 1 - Seems to work fine, when I type into console.
new Date()
Mon Mar 25 2019 12:58:45 GMT-0400 (Eastern Daylight Time)
new Date("3/25/2019 12:29:51 PM")
Mon Mar 25 2019 12:29:51 GMT-0400 (Eastern Daylight Time)
Page 2 - For some reason parsing fails and returns a completely wrong Date
value
new Date()
Mon Mar 25 2019 12:58:52 GMT-0400 (Eastern Daylight Time)
new Date("3/25/2019 12:29:51 PM")
Wed Dec 31 1969 19:00:00 GMT-0500 (Eastern Standard Time)
I also noticed that on page 1, Date.parse("3/25/2019 12:29:51 PM")
works but when I try the same on page 2, it returns null
.