如何获取到一天所有时间的数组

如何获取到一天内从00:00:00到23:59:59所有时间的数组

let h1 = "",
    m1 = "",
    s1 = "",
    h = "",
    m = "",
    s = "",
    timestr = "",
   arr = []
 for(let i=0;i<86400;i++){
  h1=parseInt(i/60/60)
  h = h1<10?"0"+h1:h1
  m1 = Math.floor((i / 60 % 60)) < 10 ? '0' + Math.floor((i / 60 % 60)) : Math.floor((i / 60 % 60));
  m=m1
  s1=parseInt(i%60)
  s = s1<10?"0"+s1:s1
  timestr = h+":"+m+":"+s
  arr.push(timestr)
 }
 console.log(arr)

 

 

 

如何获取到一天内从00:00到23:59所有时间的数组

let h1  = "",
    m1  = "",
    h  = "",
    m  = "",
    timestr = "",
    arr=[]
 for(let i=0;i<1440;i++){
  h1=parseInt(i/60)
  h = h1<10?"0"+h1:h1
  m1=parseInt(i%60)
  m = m1<10?"0"+m1:m1
  timestr = h+":"+m
  arr.push(timestr)
 }
 console.log(arr)

posted @ 2020-01-09 15:35  SHY13  阅读(495)  评论(0编辑  收藏  举报