Reputation: 2121
Facing a problem with JavaScript Date
function, returns "Date {Invalid Date}"
in Firefox browser but 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}
Upvotes: 4
Views: 6151
Reputation: 1204
This works in all browsers -
new Date('2001/01/31 12:00:00 AM')
Upvotes: 5
Reputation: 29549
Date does not take a timezone parameter in that way. My thought is that Chrome is just ignoring it.
new Date(year, month, day [, hour, minute, second, millisecond])
Please see @Brett's comment below for more information.
Upvotes: 2
Reputation: 220
Make sure the parameter is RFC1123 compliant: https://www.rfc-editor.org/rfc/rfc1123
Upvotes: 1