我的目标是让计时器在指定的时间启动(确实如此),但是我不想要日期(2019年1月29日),我只想要时间,这样我就不必更新日期每一天。关于如何更改for()在时间而非日期范围内工作的任何建议?
我尝试仅删除日期并留下时间,因此无法使用。
var schedule = [
['Jan 29, 2019 20:43:00', 'Jan 29, 2019 21:48:05']
]
<!-- Mainly this part -->
for(var i=0; i<schedule.length; i++){
var startDate = schedule[i][0];
var endDate = schedule[i][1];
// put dates in milliseconds for easy comparisons
var startMs = Date.parse(startDate);
var endMs = Date.parse(endDate);
var currentMs = Date.parse(new Date());
// if current date is between start and end dates, display clock
if(endMs > currentMs && currentMs >= startMs ){
initializeClock('clockdiv', endDate);
openRequestedPopup();
myStopFunction();
setInterval(function(){window.location.reload(5);}, 306000);
setTimeout(function () { windowObjectReference.close();}, 305000);
}
仅显示带有日期和时间的计时器,我只希望计时器仅显示开始时间和结束时间。
答案 0 :(得分:0)
根据我的评论,如果是这样的话,这样的事情应该起作用:
tsil = ['input',]
while True:
print('Write A Number (Print "done" When Finished)')
num = input()
tsil.append(num)
print()
if num == 'done':
break
if True == True:
print(tsil)
def a():
print('you like short lists? (True or False)')
ans = input()
if ans == 'True' or 'true':
return '\ngood for you'
elif ans == 'False' or 'false':
return '\nstop making short lists then'
else:
return '\nstop printing the wrong things loser'
def b():
print('you like long lists? (True or False)')
ans = input()
if ans == 'True' or 'true':
return '\ngood for you'
elif ans == 'False' or 'false':
return '\nstop making short lists then'
else:
return '\nstop printing the wrong things loser'
if len(tsil) < 10:
print('^ short list large gorge')
print()
print(a())
else:
print('^ big boy list')
print()
print(b())
答案 1 :(得分:0)
var schedule = [
['Jan 30, 2019 10:40:00', 'Jan 30, 2019 12:12:05']
];
for(var i=0; i<schedule.length; i++){
var startDate = schedule[i][0];
var endDate = schedule[i][1];
// put dates in milliseconds for easy comparisons
var startMs = Date.parse(startDate);
var endMs = Date.parse(endDate);
var currentMs = Date.parse(new Date());
// if current date is between start and end dates, display clock
if( currentMs >= startMs && currentMs<endMs){
var id = setInterval(function(){ printTime(); }, 1000);
function printTime(){
var time = new Date();
currentMs = time.getTime();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
document.write(hours + " " + minutes+" " + seconds+" ");
if(currentMs>=endMs)
clearInterval(id);
}
}
}
检查此内容可能对您有帮助... 继续学习.....