在youtube中,您可以每7分钟为视频添加一次广告。我想要加7分钟142次。并在
中打印console.log();
答案 0 :(得分:0)
// New date object, initialized to "zero"
var d = new Date(0, 0, 0, 0, 0, 0);
// While the hours property of the Date object is less than 10
while (d.getHours() < 10) {
// Get hours part and pad with a 0 if necessary
var hoursString = d.getHours().toString();
if (hoursString.length == 1) {
hoursString = "0" + hoursString;
}
// Get minutes part and pad with a 0 if necessary
var minutesString = d.getMinutes().toString();
if (minutesString.length == 1) {
minutesString = "0" + minutesString;
}
// Log the time
console.log(hoursString + ':' + minutesString);
// Add 7 minutes and let the Date object handle overflow to hours internally
d.setMinutes(d.getMinutes() + 7);
}
您可以找到有关日期对象here的更多信息。