需要在第二天显示(脚本显示当天)

时间:2015-10-27 09:34:40

标签: php html

<body>
<?php
date_default_timezone_set('Pacific/Fiji');
$day = date('l', mktime());
$day = strtolower($day).".html";

/*
$path = $_SERVER['SCRIPT_FILENAME'];
$trace = explode("/", $path);
$count = count ($trace) - 1;
$trace[$count] = $day;
$path = implode("/", $trace);
echo $path;
*/

if (file_exists($day)) 
{
    include($day); 
}
?>
</body>

4 个答案:

答案 0 :(得分:0)

第二天的简单方法是使用strtotime:

echo date('l', strtotime(date("Y-m-d") .' +1 day'));

你可以跳过日期(“Y-m-d”),我在那里向你展示,你可以从你想要的任何日期获得+1天

答案 1 :(得分:0)

你有没有尝试过?

$date = new DateTime('2015-10-27 12:00:00'); // pick a date (today)

echo $date->format('Y-m-d H:i:s'); // show it

$date->modify('+1 day'); // add + 1 day

echo $date->format('Y-m-d H:i:s'); // shows tomorrow

答案 2 :(得分:0)

<body>
<?php
date_default_timezone_set('Pacific/Fiji');
$day = date('l', strtotime('+1 day'));
/*
$path = $_SERVER['SCRIPT_FILENAME'];
$trace = explode("/", $path);
$count = count ($trace) - 1;
$trace[$count] = $day;
$path = implode("/", $trace);
echo $path;
*/

if (file_exists($day)) 
{
    include($day); 
}
?>
</body>

更新了代码的更改,以显示一周的第二天。

答案 3 :(得分:0)

<body>    
<?php    
date_default_timezone_set('Pacific/Fiji');    
$day = date('l', strtotime(date($day) .' +1 day'));    
$day = strtolower($day).".html";
/*    
$path = $_SERVER['SCRIPT_FILENAME'];    
$trace = explode("/", $path);    
$count = count ($trace) - 1;    
$trace[$count] = $day;    
$path = implode("/", $trace);    
echo $path;    
*/

if (file_exists($day))     
{    
    include($day);     
}    
?></body>