Обновить страницу в определенное время и конкретную дату [дубликаты]

0

Я использую код 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);
  • 0
    function refreshAt(hours, minutes, seconds, day, month, year) не очень хорошо подходит для refreshAt(13,12,2013,21,25,00) .
  • 0
    я изменил на refreshAt (22,25,00,13,12,2013); но не работает также
Показать ещё 2 комментария
Теги:
refresh

1 ответ

1

Я бы рекомендовал другой подход, без JavaScript (чистый HTML):

<meta http-equiv="refresh" content="<?php echo getRemainingSecondsToRefresh() ?>">
  • 0
    Вы правы, но как я могу справиться с этим. я хочу сказать, что хочу обновить в определенную дату и время? как его работа?
  • 0
    кто-нибудь здесь, кто может мне помочь?
Показать ещё 1 комментарий

Ещё вопросы

Сообщество Overcoder
Наверх
Меню