An interesting js get yesterday's date bug

Because of company requirements, the default date after one of my pages is opened is yesterday. The code is

 var date = myDate.getDate() - 1;//获取昨日

But on the first day of 2021, something strange happened, opening the page showing 2021-1-0. So even the procedure feels that 2020 is too difficult, don't you want to go back?
Happy New Year's Day everyone, don’t go to work like me~

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42094764/article/details/112062549