User Contributed Notes: filemtime
benbatten@home.com
29-Apr-1999 09:45
I was trying to figure out how to glean a simple "file last modified" time/date stamp while experimenting with PHP on Win95 (shudder) with PWS. filemtime() returned Unix epoch time in seconds. Here is a solution to get the 12 hour time and standard date format, for what its worth:
<PRE>
$filemod = filemtime(__FILE__);
$filemodtime = date("F j Y h:i:s A", $filemod);
Print("File last modified $filemodtime");
</PRE>
This will output the month, day of month, year and time (12 hour format) of the file's last modification.
gerardj@home.com
19-May-1999 08:27
The above code works fine if you place it on each page you want a date stamp on. I've found that if you place a reference such as <pre>filemtime(__FILE__)</pre> in an included or required file, that the modification time of the inherited file will be returned, not the time of the file that did the ineriting.
jay@fudge.org
29-Jun-1999 01:55
If you want this functionality for the parent web page you should use getlastmod()
i.e.
<pre><?php echo "Last modified: ".date( "F d Y H:i:s.", getlastmod() ); ?></pre>
within the included page... i.e. as a commont footer include for all pages
ian@eiloart.com
23-Jul-1999 08:56
See <a href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fja%2F%26quot%3Bhttp%3A%2Fwww.php.net%2Fmanual%2Ffunction.stat.php3%26quot%3B%26gt%3Bthis&y=1999 note</a> for the difference between filemtime and filectime.
chopin@csone.kaist.ac.kr
27-Aug-1999 02:36
It does not work when $filename is http url, you must read it from url header by socket open. see <a href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fja%2F%26quot%3Bhttp%3A%2Fwww.phpwizard.net%2FphpTidbits%2F%26quot%3B%26gt%3BphpTidbits-Socket&y=1999 operations</a>
webmaster@info-loe.de
10-May-2000 05:48
How i can get the lastmodified date from an url like http://www.php.net/index.html
dursh@sutjav.com
15-Aug-2000 03:30
I can't seem to get filemtime to work for me when working with Mac files? I'm on a Win NT machine using PWS, and I need to get the dates from a CD with files created on a Mac. The dates view fine in Windows Explorer and DOS, but when trying the filemtime method with PHP, I keep getting "December 31, 1969, 7:00 pm"? Can somebody please tell me if there is a way to get the proper date from my Mac CDs?