Surya Badrinath Surya Badrinath - 3 months ago 9
Node.js Question

new Date() function is giving an unwanted Date String

I am using a function to create a Data object using new Date() function as,

var a = new Date();


It gives me a string like "2016-08-26T08:45:50.408Z" in some case, and this in most cases --> "Thu Aug 25 06:57:10 PDT 2016". I want to know why is there such a difference. Please suggest some method to solve this. I want the format to be only in "2016-08-26T08:45:50.408Z". Thanks

aba aba
Answer

Do this ..

moment("Thu Aug 25 06:57:10 PDT 2016").toISOString();

output: "2016-08-25T13:57:10.000Z"