获取未来时间年月日

简介: 获取未来时间年月日

获取未来时间年月日

var getFutureDate = (breakDate) => {
  let arr = new Array(breakDate);
  for(let i=0;i<arr.length;i++){
  let thisTime = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * i);
  let fullYear=thisTime.getFullYear();
  let month=(thisTime.getMonth() + 1);
  let date=thisTime.getDate();
    arr[i]=`${fullYear}-${month}-${date}`
}
  return arr
}
console.log(getFutureDate(7));
// 0: "2022-9-29"
// 1: "2022-9-30"
// 2: "2022-10-1"
// 3: "2022-10-2"
// 4: "2022-10-3"
// 5: "2022-10-4"
// 6: "2022-10-5"

相关文章
|
9月前
|
存储 C语言 C++
c++日期和时间
c++日期和时间
54 0
|
9月前
年月日
年月日
59 0
|
9月前
|
C语言 C++
c++日期&时间
c++日期&时间
68 1
|
9月前
|
前端开发 索引
前端获取当前日期---------------年月日//时分秒
前端获取当前日期---------------年月日//时分秒
91 0
jeDate可提供选择日期不超过当前日期
jeDate可提供选择日期不超过当前日期
95 1
获取当前日期和时间
获取当前日期和时间
179 0
|
Java
获取当前日期时间
获取当前日期时间
157 0
|
测试技术
日期和时间处理
日期和时间处理
209 0
1185. 一周中的第几天 : 简单日期统计模拟题
1185. 一周中的第几天 : 简单日期统计模拟题