« Funny Business: The Paradoxical Nature of Business Success | Main | Friday Flapdoodle »

Using PHP to Display a File Date

Thank you to everyone who has sent in suggestions on how to solve my problem of time stamping a jpeg or html file. I now have more suggestions than I could possibly test in a week. I will post solutions as I can find the time to do so.

So far, one suggestion that works is from Rick Hellewell:

<?php
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
$filename = 'somefile.txt';
if (file_exists($filename))
{
echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>

I believe it assumes that the 'somefile.txt' is in the current directory (the directory that the current PHP page is in). I got it from the PHP pages here: http://us3.php.net/manual/en/function.filemtime.php. And the extension of the web page needs to be PHP. ...Rick...

You insert the the above code into a web page anywhere between the <body> </body>tags, make sure the name of the web page has the .php extension and, assuming your web server is setup to use PHP, Bob's your Uncle, it works!

But for now, thank you to Peter Thomas, fellow Daynoters Rick Hellewell and John Domonik, and Frank Fitz for sending in suggestions/examples. I will get to each as soon as I can. If I missed anyone I apologize, it was purely unintentional.

Aloha!

About

This page contains a single entry from the blog posted on November 3, 2005 6:24 AM.

The previous post in this blog was Funny Business: The Paradoxical Nature of Business Success.

The next post in this blog is Friday Flapdoodle.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.34