I want to do same thing as How do I get the number of days between two dates in JavaScript?
but I want do the same on this date format: 2000-12-31
.
function daysBetween(date1String, date2String){
var d1 = new Date(date1String);
var d2 = new Date(date2String);
return (d2-d1)/(1000*3600*24);
}
console.log( daysBetween('2000-12-31', '2005-05-04') ); //-> 1585
ISO8601 date strings are recognized by JavaScript directly. No need to parse them yourself.