在缓存页面上显示PHP时间戳

在缓存页面上显示PHP时间戳,php,wordpress,caching,timestamp,Php,Wordpress,Caching,Timestamp,我正在使用 <?php include ('/time.php'); ?> 以下是我从另一篇SE帖子中获得的代码: <?php date_default_timezone_set('America/Chicago'); // timezone $weekday = date(l); // today // print $weekday; // Debug // print date("H:i"); // debug // Se

我正在使用

<?php include ('/time.php'); ?>

以下是我从另一篇SE帖子中获得的代码:

<?php
    date_default_timezone_set('America/Chicago'); // timezone 

    $weekday = date(l); // today
    // print $weekday; // Debug
    // print date("H:i"); // debug

    // Set open and closing time for each day of the week
    if ($weekday != "Saturday" || $weekday != "Sunday") {
        $open_from = "07:00";
        $open_to = "24:00";
    }

    // now check if the current time is before or after opening hours
    if (date("H:i") < $open_from || date("H:i") > $open_to ) {
        print "House: We're closed for the day.";
    }

    else {
        print "Hours: We're open!";
    }
?>
试试看

这将添加无缓存标头:

'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
'Last-Modified'] = false,
发送到要发送的HTTP头

'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',
'Cache-Control' => 'no-cache, must-revalidate, max-age=0',
'Last-Modified'] = false,