Angularjs stores the values of data type controls using the date object Javascript. To subtract two dates, you can use the method .getTime()
which returns the number of milliseconds passed between the date in question and January 1, 1970 (GMT).
Then, by converting the two, you can subtract from each other and find the number of milliseconds between one and the other. Divide the result by (24 * 60 * 60 * 1000)
and you have the number of days between the two dates.
var dias = (startDay.getTime() - endDay.getTime()) / 86400000;
if (dias == 1) console.log("Correto!");
You can use lib Moment js to handle dates. It will be much easier using this lib, because handling dates in javascript in hand is boring as hell. hehe
– Kayo Bruno
Yes but I think this project I’m working on has enough lib, thank you
– Bruno H.
Bruno, did any of the answers solve your problem?
– Sergio
Yes, they all helped me to arrive at the solution and to think differently, thank you
– Bruno H.