Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在特定时间和特定日期刷新页面_Javascript_Php_Html_Refresh - Fatal编程技术网

Javascript 在特定时间和特定日期刷新页面

Javascript 在特定时间和特定日期刷新页面,javascript,php,html,refresh,Javascript,Php,Html,Refresh,我使用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")?>');

我使用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);
函数刷新时间(小时、分钟、秒、日、月、年){
var now=新日期(“”);
var则=新日期(“”);
如果(now.getHours()>hours||
(now.getHours()==hours&&now.getMinutes()>minutes)||
now.getHours()==hours&&now.getMinutes()==minutes&&now.getSeconds()>=seconds){
然后是.setDate(现在是.getDate()+1);
}
然后。设定日(日);
然后,设置月(月);
然后,设置年份(年);
然后,设定小时数(小时);
然后,设置分钟(分钟);
然后。设置秒(秒);
var timeout=(then.getTime()-now.getTime());
setTimeout(函数(){
window.location.reload(true);
window.location=“load.php”;
},超时);
}
refreshAt(13,12,2013,21,25,00);

我推荐另一种方法,不使用JavaScript(纯HTML):


函数refreshAt(小时、分钟、秒、日、月、年)
似乎与
refreshAt(13,122013,21,25,00)
不匹配。我改为refreshAt(22,25,00,13,122013);但它也不起作用这里有谁能帮我?请不要发布重复的问题。你几个小时前已经发布了这个问题。你是对的,但我如何处理它。我的意思是说我想在特定的日期和时间刷新?它是如何工作的?这里有谁能帮我吗?你需要计算秒数,用
getRemainingSecondsToRefresh
方法从
特定日期和时间中减去
now
)。
<meta http-equiv="refresh" content="<?php echo getRemainingSecondsToRefresh() ?>">