gpt4 book ai didi

javascript - 如何每十分钟获取一次日期数据

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:27:44 24 4
gpt4 key购买 nike

你知道生成每10分钟推进一次的日期数据并放入数组的好方法吗?


let dts:Dates = new array();

let dt: Date = new Date('2019-05-03T06:00:00');
let dt2: Date = new Date('2019-05-03T06:00:00');
let dt3: Date = new Date('2019-05-03T06:00:00');

dt.setMinutes(dt.getMinutes() + 10);
console.log(dt);
dt2.setMinutes(dt.getMinutes() + 10);
console.log(dt2);
dt3.setMinutes(dt2.getMinutes() + 10);
console.log(dt3);


while(dt.getTime()<= 6 ){ // I would like from 6:00 , 6:20 ... (7:00) Is it impossible to add 7:00?
dt.setMinutes(dt.getMinutes() + 10);
console.log(dt);
}

最佳答案

    var origDateObj = new Date();
var updatedDateObj = new Date();

//The 10 in the line below will determine the amount of time added.
updatedDateObj.setTime(origDateObj.getTime() + (10 * 60 * 1000));

console.log(updatedDateObj);

关于javascript - 如何每十分钟获取一次日期数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58205798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com