JavaScript date function returns "Date {Invalid date}" in Firefox

Before there is a problem with the JavaScript Date function, returns "Date {Invalid Date}" in Firefox, but it works fine in Google Chrome.

 // My Input is new Date("Sat Jan 01 00:00:00 EST 1"); // Works fine in google chrome // Result: Mon Jan 01 2001 10:30:00 GMT+0530 (India Standard Time) // Not working in Firefox (Version: 15.0.1) // Result: Date {Invalid Date} 
+4
source share
3 answers

Date does not accept the time zone parameter in this way. I thought Chrome was just ignoring this.

 new Date(year, month, day [, hour, minute, second, millisecond]) 

See @Brett's comment below for more details.

+2
source

This works in all browsers -

new date ('2001/01/31 12:00:00 AM')

+5
source

Make sure the parameter matches RFC1123: http://tools.ietf.org/html/rfc1123

+1
source

Source: https://habr.com/ru/post/1438934/


All Articles