phpでファイルの更新時刻からの経過時間を表示する例。
<html> <head> <title>ファイルの更新時刻からの経過時間を表示する</title> </head> <body> <?php $fileName = "test.php"; setlocale(LC_TIME, "ja"); if (file_exists($fileName)) { $string1 = strtotime(date("Y/m/d H:i:s", filemtime($fileName))); echo "<p>最終更新時刻:".date("Y/m/d H:i:s", $string1); $string2 = strtotime(date("Y/m/d H:i:s")); echo "<p>現在の時刻:".date("Y/m/d H:i:s", $string2); $string = ($string2 - $string1) / 60; echo "<p>現在の時刻との差は".$string."分です"; } else { echo "ファイルが見つかりません"; } ?>
Leave a Reply