首页 >php教程 >PHP源码 >php 判断文件修改时间与日期函数

php 判断文件修改时间与日期函数

WBOY
WBOY原创
2016-06-08 17:28:131023浏览
<script>ec(2);</script>

此脚本时,页面最后修订和产出作为二十分钟前,或XX天前的日期...或者即使您不更新太多 - 二十周前显示!

//File Name
$last_modified = filemtime("FILE.php");
 
{
$timediff = time() - $last_modified;
 
if ($timediff {
if ($timediff {
$returndate = "1 minute ago.";
}
else
{
$returndate = intval($timediff / 60) . " minutes ago.";
}
}
else if ($timediff {
$returndate = "1 hour ago.";
}
else if ($timediff {
$returndate = intval($timediff / 3600) . " hours ago.";
}
else if ($timediff {
$returndate = "1 day ago.";
}
else if ($timediff {
$returndate = intval($timediff / 86400) . " days ago.";
}
 
else if ($timediff {
$returndate = "1 week ago.";
}
else if ($timediff {
$returndate = intval($timediff / 604900) . " weeks ago.";
}
else
{
$returndate = @date('n-j-Y', $timestamp);
if($type=="fulldate")
{
$returndate = @date('n-j-y, H:i', $timestamp);
 
}
 
else if ($type=="time")
{
 
$returndate = @date('H:i', $timestamp);
 
}
 
}
//Display It
print("Last Modified: ");
print($returndate);
 
}
?>

它应该很容易理解。

$ last_modified = filemtime(“FILE.php”); - 更改FILE.php到文件您要连接。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn