Entry
How do I display a "Last Modified ..." date?
Aug 3rd, 2000 13:57
Philip Olson, php.net
An example is:
<?php
putenv("PHP_TZ=America/Los_Angeles");
echo "Last Modified:" . date( "F d, Y. H:i:s a", getlastmod() );
?>
this prints the files last modification date in the following format:
Last Modified: May 21, 2000. 14:59:02 am
keep in mind that much of the above is not required, here is a trimmed
down version:
<?php
echo date( "F d, Y. H:i:s a", getlastmod() );
?>
this prints:
May 21, 2000. 22:59:02 am
the time is different as my server is eight hours ahead of me!
Notes:
timezone: putenv adds the timezone which in this case is PST.
strings: the "F d, Y. H:i:s a" simply dictates the format of your given
last modification date. For instance, let's say we did this:
<?php
echo date( "m/d/Y", getlastmod() );
?>
this prints:
5/21/2000
---
To implement, either put this code straight into your footer or
sometimes it's nice to include it like:
<? include "lastmodified.inc" ?>
with of course lastmodified.inc containing a script simular to the ones
found above.
---
references:
putenv: http://www.php.net/manual/html/function.putenv.html
getlastmod: http://www.php.net/manual/html/function.getlastmod.html
date/time: http://www.php.net/manual/ref.datetime.php3
tutorial: http://www.theprojects.org/dev/lastmodified.html