我在特定時間使用JavaScript代碼進行刷新。我想在特定的時間和日期刷新頁面。我如何在此代碼中添加日期?在特定時間和特定日期刷新頁面
function refreshAt(hours, minutes, seconds, day, month, year) {
var now = new Date('<?php echo date("d M Y H:i:s")?>');
var then = new Date('<?php echo date("d M Y H:i:s")?>');
if (now.getHours() > hours ||
(now.getHours() == hours && now.getMinutes() > minutes) ||
now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
then.setDate(now.getDate() + 1);
}
then.setDay(day);
then.setMonth(month);
then.setYear(year);
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);
var timeout = (then.getTime() - now.getTime());
setTimeout(function() {
window.location.reload(true);
window.location = "load.php";
}, timeout);
}
refreshAt(13, 12, 2013, 21, 25, 00);
'函數refreshAt(小時,分,秒,日,月,年)'似乎並不匹配' refreshAt(13,12,2013,21,25,00)'很好。 –
我改成refreshAt(22,25,00,13,12,2013);但它的不工作也 – user3099986
任何一個誰可以幫助我? – user3099986