I have below calculation:
vCurrDate = new Date();
vDueFromDate = new Date();
vDueToDate = new Date();
vOverDueToDate = new Date();
vCurrDate.setDate(vCurrDate.getDate() - 1);
vDueFromDate.setDate(vCurrDate.getDate() - 30);
vDueToDate.setDate(vCurrDate.getDate());
vOverDueToDate.setDate(vCurrDate.getDate() - 31);
On March 02 2018 (today), all the above calculations are working fine. But, on March 01 2018, last three calculations went wrong. Below shows the result of above calculations with both mentioned dates:
--On March 02 2018 (today)
Thu Mar 01 2018 12:03:34 GMT+0530 (India Standard Time) **** 01-Mar-2018
Tue Jan 30 2018 12:03:34 GMT+0530 (India Standard Time) **** 30-Jan-2018
Thu Mar 01 2018 12:03:34 GMT+0530 (India Standard Time) **** 01-Mar-2018
Mon Jan 29 2018 12:03:34 GMT+0530 (India Standard Time) **** 29-Jan-2018
--On March 01 2018 (yesterday)
Wed Feb 28 2018 12:12:32 GMT+0530 (India Standard Time) **** 28-Feb-2018
Mon Feb 26 2018 12:12:32 GMT+0530 (India Standard Time) **** instead of 29-jan-2018
Wed Mar 28 2018 12:12:32 GMT+0530 (India Standard Time) **** 28-Feb-2018
Sun Feb 25 2018 12:12:32 GMT+0530 (India Standard Time) **** 28-jan-2018