定义
PHP函数filemtime()返回文件最后修改的时间。
语法
PHP filemtime()函数具有以下语法。
filemtime(filename)
参数
| 参数 | 是否必须 | 描述 |
|---|---|---|
| filename | 需要。 | 要检查的文件 |
返回值
它返回时间的Unix时间戳,然后您需要调用date()进行转换。
成功时此函数返回最后修改时间,Unix时间戳,失败时为FALSE。
注意
此函数的结果被缓存。使用clearstatcache()清除缓存。
实例
filemtime()函数返回上次修改文件内容的时间。
<?php
/*
http://www.manongjc.com/article/1785.html
作者:码农教程
*/
$contacts = \"test.txt\";
$atime = fileatime($contacts);
$mtime = filemtime($contacts);
$atime_str = date(\"F jS Y H:i:s\", $atime);
$mtime_str = date(\"F jS Y H:i:s\", $mtime);
print \"File last accessed: $atime_str\\n\";
print \"File last modified: $mtime_str\\n\";
echo filemtime(\"test.txt\");
echo \"\\n\";
echo \"Last modified: \".date(\"F d Y H:i:s.\",filemtime(\"test.txt\"));
?>
上面的代码生成以下结果:
继续阅读与本文标签相同的文章
下一篇 :
php fileowner()函数
-
5G核心网建设是采用SA独立组网还是NSA独立组网
2026-05-15栏目: 教程
-
买了iPhone手机,旧设备上数据怎样迁移,这有3种办法快速解决
2026-05-15栏目: 教程
-
昔日电商巨头轰然倒塌!烧光几十亿补贴后,欠下工资5600万
2026-05-15栏目: 教程
-
从做流量的梦到踏实做生意,小程序成为互联网逆袭工具!
2026-05-15栏目: 教程
-
Uber在巴黎上线摩托车租赁服务,加速共享两轮布局对击Lyft
2026-05-15栏目: 教程
