zulu date

Talk about add-ons and extension development.
Post Reply
Diamanti
Posts: 778
Joined: June 12th, 2008, 9:02 am

zulu date

Post by Diamanti »

why this code:

Code: Select all

var zStr="Fri, 04 Nov 2016 07:36:23Z"
alert(new Date(zStr));
work in Chrome and IE while in Firefox a obtain a "invalid date"?
how to fix it?
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: zulu date

Post by morat »

Can you change the date string to a different format?

Code: Select all

//  Chrome: Fri Nov 04 2016 02:36:23 GMT-0500 (Central Daylight Time)
// Firefox: Invalid Date
alert(new Date("Fri, 04 Nov 2016 07:36:23Z"));

Code: Select all

//  Chrome: Fri Nov 04 2016 02:36:23 GMT-0500 (Central Daylight Time)
// Firefox: Fri Nov 04 2016 02:36:23 GMT-0500 (Central Standard Time)
alert(new Date("2016-11-04T07:36:23Z"));

Code: Select all

//  Chrome: 1478244983000
// Firefox: 1478244983000
alert(new Date("2016-11-04T07:36:23Z").getTime());
new Date() is working in Chrome but not Firefox
http://stackoverflow.com/questions/3257460
Post Reply