PHP 8.3.4 Released!

SplFileInfo::getCTime

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplFileInfo::getCTimeinode 変更時刻を取得する

説明

public SplFileInfo::getCTime(): int|false

ファイルの inode が変更された時刻を返します。返される時刻は Unix タイムスタンプ形式です。

パラメータ

この関数にはパラメータはありません。

戻り値

最終変更時刻を Unix タイムスタンプで返します。 失敗時に false を返します。

エラー / 例外

エラー時に RunTimeException をスローします。

例1 SplFileInfo::getCTime() の例

<?php
$info
= new SplFileInfo('example.jpg');
echo
'Last changed at ' . date('g:i a', $info->getCTime());
?>

上の例の出力は、 たとえば以下のようになります。

Last changed at 1:49 pm

参考

add a note

User Contributed Notes 1 note

up
8
michael at smith-li dot com
9 years ago
A file's ctime is it's inode change time. The inode changes when file metadata changes (for example when file permissions change). The inode also changes whenever the file's contents change, but since the inode changes for other reasons, it's more accurate to use mtime to get the age of the contents of a file. See SPLFileInfo::getMTime

Also, please note ctime is not creation time. (Most UNIX-like filesystems do not record a file's creation time.)
To Top