当前位置:   article > 正文

js 获取当前时间的上个月的时间

js知道当前的时间获取一个月之前的

可以使用以下方法获取当前时间的上个月的时间:

  1. const currentDate = new Date();
  2. const lastMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() - 1, currentDate.getDate());
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号