Javascript New Date() / UTC - GMT cross browser -


the issue: different formats new date() in ie 10 - ie 11. javascript:

ie 11 / chrome :

var m = new date("2014-07-04t04:00:00");  console.log(m); // fri jul 04 2014 06:00:00 gmt+0200 (w. europe summer time)  

ie 10:

var m = new date("2014-07-04t04:00:00");  console.log(m); // fri jul 4 04:00:00 utc+0200 2014  

is possible use 1 ring rule them all?

you shouldn't pass string new date, reason.

instead, should either give individual arguments:

new date(2014, 6, 4, 4, 0, 0); // remember months zero-based 

or, if want give time in utc, try:

var d = new date(); d.setutcfullyear(2014); d.setutcmonth(6); d.setutcdate(4); d.setutchours(4); d.setutcminutes(0); d.setutcseconds(0); d.setutcmilliseconds(0); 

you can, of course, make function this.

alternatively, if have timestamp, can do:

var d = new date(); d.settime(1404446400000); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -