JS获取当前时间的前n天/后n天

踩坑参照:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84304625

在vue中使用js实现日期联动时遇到过坑,所以正确获取n天前后的方法是:

Date curDate = new Date();
var preDate = new Date(curDate.getTime() - n*24*60*60*1000); //前n天
var nextDate = new Date(curDate.getTime() + n*24*60*60*1000); //后n天

猜你喜欢

转载自blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/84304580