可以使用以下方法获取当前时间的上个月的时间:
const currentDate = new Date();
const lastMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, currentDate.getDate());
该文章介绍了一种使用JavaScriptDate对象来获取当前时间上一个月日期的方法。通过创建一个新的Date实例,然后调整月份为当前月份减1,即可得到上个月的日期。
可以使用以下方法获取当前时间的上个月的时间:
const currentDate = new Date();
const lastMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, currentDate.getDate());
790
1万+
1472
3535

被折叠的 条评论
为什么被折叠?