分享

php文件创建时间(filectime)、修改时间(filemtime)

 xf_baby 2013-11-14

发布:thebaby   来源:net     【  

本文分享三例php代码,学习下php处理文件的创建时间、修改时间以及访问时间的方法,学习下filectime、filemtime、filteatime的用法。有需要的朋友参考下。

1,php文件的创建时间的例子
 

复制代码代码示例:
<html>
<head>
<title>文件的创建时间-www.</title>
</head>
<body>
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
   if ( ! file_exists( $f ) ){
       print "$f does not exist<BR>";
      return;
   }
   print "$f 创建于:".date( "D d M Y g:i A", filectime( $f ) )."<br>";
}
?>
</body>
</html>

2,php文件的修改时间
 

复制代码代码示例:
<html>
<head>
<title>文件的修改时间-www.</title>
</head>
<body>
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
   if ( ! file_exists( $f ) ){
       print "$f does not exist<BR>";
      return;
   }
   print "$f 修改于:".date( "D d M Y g:i A", filemtime( $f ) )."<br>";
}
?>
</body>
</html>

3,php文件的最后访问时间
 

复制代码代码示例:
<html>
<head>
<title>文件的最后访问地时间-www.</title>
</head>
<body>
<?php
$file = "test.txt";
outputFileTestInfo( $file );
function outputFileTestInfo( $f ){
   if ( ! file_exists( $f ) ){
       print "$f does not exist<BR>";
      return;
   }
   print "$f 最后访问时间为:".date( "D d M Y g:i A", fileatime( $f ) )."<br>";
}
?>
</body>
</html>
本文地址:http://www./article/filectime_filemtime_fileatime_w1x3r.html

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多