+ 4
i needed a code to find difference between two dates using js
2 Answers
0
Create a function and set the two dates into variables, inside the function. Then subtract the two and save it to âresultâ.
function dateDiff() {
var d1 = date one;
var d2 = date two;
result = d1 - d2;
return result;
}
Or you can console.log result in the function like so:
console.log(result);
So when you call the function, it will automatically return the results to the console.