I've got a string which represents date. I turn it into date object and count another date one month ahead. Then I want to count the difference in days between them but I don't know why both became the same and the final resault is always zero. How can I do it?
var dateString = '2017-08-03';
var dateFrom = new Date(dateString);
console.log(dateFrom); //Thu Aug 03 2017 02:00:00 GMT+0200 (CEST)
var dateTo = new Date(dateFrom.setMonth(dateFrom.getMonth()+1));
console.log(dateTo); //Sun Sep 03 2017 02:00:00 GMT+0200 (CEST) (one month later)
console.log(dateFrom); //Sun Sep 03 2017 02:00:00 GMT+0200 (CEST)// (two dates turn into the same)
var difference = Math.floor((dateTo - dateFrom) / 86400000); // 0