Reputation: 2386
If I run new Date() on my local node I get it in UTC format:
2017-08-16T10:04:45.809Z
If I run it on my test server, I get
Wed Aug 16 2017 12:04:49 GMT+0200 (CEST)
Both times are correct. In neither cases the result is string, as far as I know. Why am I getting different format for the date, depending where I run the function? What can affect the output of new Date()?
Upvotes: 0
Views: 300
Reputation: 6956
new Date() returns a date object. What you see is the date object converted to string (to print it out) applying the locale that can be different on two machines. Please, also note that new Date() returns the date and time including time zone set on the machine where the command is executed
Upvotes: 2