downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

filectime> <file
Last updated: Fri, 06 Nov 2009

view this page in

fileatime

(PHP 4, PHP 5)

fileatimeファイルの最終アクセス時刻を取得する

説明

int fileatime ( string $filename )

指定したファイルの最終アクセス時刻を取得します。

パラメータ

filename

ファイルへのパス。

返り値

ファイルの最終アクセス時刻を返し、エラーの場合は FALSE を返します。 時間は Unix タイムスタンプとして返されます。

例1 fileatime() の例

<?php

// 出力例 somefile.txt was last accessed: December 29 2002 22:16:23.

$filename 'somefile.txt';
if (
file_exists($filename)) {
    echo 
"$filename was last accessed: " date("F d Y H:i:s."fileatime($filename));
}

?>

注意

注意: ファイルの atime は、 ファイルのデータブロックが読み込まれる度に変更されるとみなされます。 この仕様は、アプリケーションが非常に多くのファイルまたはディレクトリに 常にアクセスする場合に性能上の負荷となる可能性があります。
Unix のファイルシステムの中には、 このようなアプリケーションの性能を向上させるために atime の更新を無効としてマウントできるものもあります。 USENET のニューススプールが一般的な例です。 このようなファイルシステムでは、この関数は使用できません。

注意: 時刻の精度は、 ファイルシステムによって異なることがあります。

注意: この関数の結果は キャッシュされます。詳細は、clearstatcache() を参照してください。

ヒント

PHP 5.0.0 以降、この関数は、 何らかの URL ラッパーと組合せて使用することができます。 どのラッパーが stat() ファミリーをサポートしているか のリストについては、サポートするプロトコル/ラッパー を参照してください。

参考

  • filemtime() - ファイルの更新時刻を取得する
  • fileinode() - ファイルの inode を取得する
  • date() - ローカルの日付/時刻を書式化する



add a note add a note User Contributed Notes
fileatime
Tyler at visualbits dot net
17-Dec-2008 04:42
This only applys to the FAT filesystem, ntfs and greater have file access time support.

Be careful with this function it can degrade script performance if checking several files.
Maulwurf
11-Oct-2004 01:12
Using this function on Win98 made me grow grey hair.
Win 98 doesn't save the time for the last access. It only saves the date. This way, the returned timestamp from fileatime(file) is always much too small.

this command will always return false:

if($now - $last_access >1800) {
do something
}

using filemtime() instead did the thing.

filectime> <file
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites