Skip to content Skip to sidebar Skip to footer

Node Js Tolocaletimestring Acting Funny In Different Environments Server Vs Laptop

So on my laptop (mac book pro) I pull up my bash and hit node to work on some date objects I get this response: $node > var d = new Date(); Sat Oct 03 2015 03:48:41 GMT-0700 (P

Solution 1:

Looks like toLocaleTimeString is not working well with the way you server is configured.

First, check the time zone in your server. See https://chrisjean.com/change-timezone-in-centos.

The other thing that will help is to use a library like moment that makes it easy and formats consistently:

var moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));

Post a Comment for "Node Js Tolocaletimestring Acting Funny In Different Environments Server Vs Laptop"