【发布时间】:2013-12-13 17:15:06
【问题描述】:
我正在使用 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);
【问题讨论】:
-
function refreshAt(hours, minutes, seconds, day, month, year)似乎与refreshAt(13,12,2013,21,25,00)不太匹配。 -
我改为 refreshAt(22,25,00,13,12,2013);但它也不起作用
-
这里有谁能帮助我吗?
-
请不要发布重复的问题。您已经在几个小时前发布了这个问题。
标签: javascript php html refresh