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.
fileatime
(PHP 4, PHP 5)
fileatime — ファイルの最終アクセス時刻を取得する
説明
int fileatime
( string $filename
)
指定したファイルの最終アクセス時刻を取得します。
パラメータ
- filename
-
ファイルへのパス。
返り値
ファイルの最終アクセス時刻を返し、エラーの場合は FALSE を返します。 時間は Unix タイムスタンプとして返されます。
例
Example#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() ファミリーをサポートしているか のリストについては、サポートされるプロトコル/ラッパー を参照してください。
fileatime
Maulwurf
11-Oct-2004 01:12
11-Oct-2004 01:12