1

In chrome's console:
(new Date(Date.now())).toLocaleString() returns "9/5/2014 9:43:08 PM"
new Date(Date.now()) returns 'Fri Sep 05 2014 21:43:08 GMT+0530 (IST)'

In node.js REPL/app:
(new Date(Date.now())).toLocaleString() returns 'Fri Sep 05 2014 21:43:18 GMT+0530 (IST)' which is the same as running new Date(Date.now())

What is the change I need to do to get the same output format as chrome.

surajck
  • 1,186
  • 9
  • 23
  • If you need to nicely (and consistently) format a date string, I'd take a look at [moment.js](http://momentjs.com). It's available for the browser and as an npm module. – Mike S Sep 05 '14 at 16:42
  • I have the same problem in node v4.1.1 in windows – alisabzevari Dec 14 '15 at 11:04
  • 1
    Possible duplicate of [Using .toLocaleString() in Node.js](https://stackoverflow.com/questions/23199909/using-tolocalestring-in-node-js) – Ashley Coolman Feb 13 '18 at 09:55

0 Answers0