我已将getlastmod函数添加到我的标题中,并在上次修改时显示所有页面。现在,如果页面在过去7天内被修改,我想在标题导航容器的每个页面链接中添加文本或小的新图标,否则不显示任何内容。我的逻辑是:(我不是程序员btw)
<?PHP
$date_modified = filemdate;
$current_date = date(Y,m,d);
$new = '/images/new.gif';
if {(current_date > date_modified + 7days);
echo "";
else {
echo $new;
}}
?>
//将$ new添加到header.php导航上的每个导航项目,如home(index.php),news(news.php),links(links.php) //容器。
答案 0 :(得分:2)
filemdate是错误的功能
你应该使用
filemtime($filename)
然后用它来比较文件时间。
答案 1 :(得分:0)
这个小片段应该这样做:
// get timestamp of last modification
$last_modified = filemtime($filename);
// get timestamp of seven days ago
$seven_days_ago = strtotime('-7 days');
// perform the comparison
if ($last_modified >= $seven_days_ago) {
echo '/images/new.gif';
}