-1

In youtube you can add ads to your video every 7 minutes. I want add 7 minutes 142 times. And print it in

console.log();
4

1 回答 1

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);
}

您可以在此处找到有关 Date 对象的更多信息。

于 2013-08-06T09:21:14.783 回答