【发布时间】:2013-08-06 09:06:04
【问题描述】:
在 youtube 中,您可以每 7 分钟将广告添加到您的视频中。我想加 7 分钟 142 次。并将其打印在
console.log();
【问题讨论】:
标签: javascript youtube
在 youtube 中,您可以每 7 分钟将广告添加到您的视频中。我想加 7 分钟 142 次。并将其打印在
console.log();
【问题讨论】:
标签: javascript youtube
// 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 的更多信息。
【讨论】: