例如给出时间 2020-09-23;算出每隔一分钟的时间如下:
[ '2020-09-23 00:00', '2020-09-23 00:01', '2020-09-23 00:02', '2020-09-23 00:03', ... '2020-09-23 23:58', '2020-09-23 23:59', ]
谢谢
function output(dateStr) { let arr = []; for (let i = 0; i <= 23; i++) { const h = i < 10 ? `0${i}`: `${i}`; for (let j = 0; j <= 59; j++) { const m = j < 10 ? `0${j}`: `${j}`; arr.push(`${dateStr} ${h}:${m}`); } } return arr; } output('2020-09-24'); // [ "2020-09-24 00:00", "2020-09-24 00:01", "2020-09-24 00:02", ...]
2.1m questions
2.1m answers
62 comments
56.7k users