I have a date object 1/10/2021
and when I set date minus 1. It will return 31/10/2021
.
What I expect here is 30/9/2021.
Here is my simulate of code:
const _date = new Date(2021, 10, 1);
_date.setDate(_date.getDate() - 1);
console.log(_date) // Sun Oct 31 2021 00:00:00 GMT+0800 (Singapore Standard Time)
Anyone can explain what wrong with my code? and how to fix this case? I really need your help in this issue.