js生成固定时间间隔的时间值-每秒递增-分钟递增-分小时递增
作者:
放下手机出来嗨 | 来源:发表于
2019-12-26 15:07 被阅读0次var lists=[];
var count=0; //初始值为0
function getTimer(start,Timer,length) {
for (let j = 0; j <length; j++) {
debugger
count += 1;
var seconds=Date.parse(start); //标准时间转毫秒数
var totals=j*Timer*1000+seconds; //固定时间间隔+开始时间的总毫秒数 分钟递增在*60 分小时 递增*60*60
var res=new Date(totals).toString().split(' ')[4];//毫秒数转字符串,截取,取值
var result=`(${count},"${res}")`;//拼装
lists.push(result)
}
}
getTimer('2019-07-25 09:05:00',1,60) //开始时间秒数,时间间隔,期数
console.log(lists)
本文标题:js生成固定时间间隔的时间值-每秒递增-分钟递增-分小时递增
本文链接:https://www.haomeiwen.com/subject/fazkoctx.html
网友评论