Search code examples
javascriptfirefoxsafaritimezoneutc

Javascript - UTC date to local date


I have the following snippet:

var d = new Date('2015-11-23T17:44:59');
var n = d.toLocaleString();
return n;

On chrome looks good:

11/23/2015, 6:44:59 PM

But on safari looks good:

23 November 2015 at 18:44:59 GMT+1

On Firefox even worse:(Showed in UTC)

11/23/2015, 5:44:59 PM 

Only Chrome works properly.


Solution

  • If you would like to output that format consistently you'll need to use a separate library - like DateJS.