I have this code that allows subtract 2 dates in yyyy-mm-dd format
to get the days difference. the date that I introduce is date of today ("2018-02-08") minus the date of tomorrow ("2018-02-09") . the result for today should be 1. I want to do it without using any external library.
how can I fix it?
var tomorrow = new Date("2018/02/08");
var one_day = 1000 * 60 * 60 * 24;
var today = new Date(); //it is dynamic, depends of the day..
console.log(Math.abs(Math.ceil((today.getTime() - tomorrow.getTime()) / one_day)));