美文网首页
获取当前日期往前推n天的日期

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

作者: MAYDAY77 | 来源:发表于2019-04-09 21:00 被阅读0次

    获取当前时间this.endDateValue:

    this.endDateValue =new Date();

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

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

    相关文章

      网友评论

          本文标题:获取当前日期往前推n天的日期

          本文链接:https://www.haomeiwen.com/subject/puhwiqtx.html