date to iso date in node js code example
Example 1: date().toisostring().slice(0 10) giving wrong result
//Add Z in the end for getting the correct value with local timezone
var a = new Date("June 08, 2018 Z");
var res = a.toISOString().slice(0, 10);
console.log(res);
Example 2: iso to date javascript
date = new Date('2013-03-10T02:00:00Z');
date.getFullYear()+'-' + (date.getMonth()+1) + '-'+date.getDate();//prints expected format.