获取当前日期往前推n天的日期

2019-04-09  本文已影响0人  MAYDAY77

获取当前时间this.endDateValue:

this.endDateValue =new Date();

然后通过getTime()方法 获取距 1970 年 1 月 1 日之间的毫秒数,减去往前推n天的毫秒数;再通过newDate()转换一下即可;

this.startDateValue =new Date(this.endDateValue.getTime() - n *24 *60 *60 *1000);

上一篇下一篇

猜你喜欢

热点阅读