I am sending date from frontend like below:
11/26/2018
Now i want to convert it into type Date, So that it can be comparable to any other date.How can i do it in node.js.
I am sending date from frontend like below:
11/26/2018
Now i want to convert it into type Date, So that it can be comparable to any other date.How can i do it in node.js.
const initialDate="11/26/2018"
let splited = initialDate.split("/");
let date=new Date(splited[2], splited[1] - 1, splited[0])
note that the months are indexed from 0.
var mydate = new Date('11/26/18');
var mydate2 = new Date('11/24/18');
console.log('String Format =',mydate.toDateString());
console.log('ISO Format =', mydate.toISOString());
if (mydate > mydate2) {
console.log('mydate is greater than mydate2');
}else{
console.log('mydate is less than mydate2');
}
you can also use moment.js