php文件的创建时间(filectime)、修改时间(filemtime)、访问时间(fileatime)
发布时间:2017-01-18 编辑:jiaochengji.com
本文分享三例php代码,学习下php处理文件的创建时间、修改时间以及访问时间的方法,学习下filectime、filemtime、filteatime的用法。有需要的朋友参考下。
1,php文件的创建时间的例子
复制代码 代码示例:
<html>
<head>
<title>文件的创建时间-www.jbxue.com</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>
<head>
<title>文件的创建时间-www.jbxue.com</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.jbxue.com</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>
<head>
<title>文件的修改时间-www.jbxue.com</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.jbxue.com</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>
<head>
<title>文件的最后访问地时间-www.jbxue.com</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>
您可能感兴趣的文章:
php获取文件的创建时间、修改时间的简单示例
php文件的创建时间(filectime)、修改时间(filemtime)、访问时间(fileatime)
php 读取文件的各种时间
PHP判断文件是否被修改实例
PHP 文件编程(一)-获取文件信息的二种方式
php写入、删除、复制文件及创建修改时间例子
PHP获取指定文件详细信息的实例代码
php函数filetime获取文件最后修改时间
php文件操作函数的实例详解
php 文件系统处理 fopen
[关闭]