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

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

WBOY
WBOYOriginal
2016-06-08 17:28:131024browse
<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到文件您要连接。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn