PHP Last Updated Script
Written by The Geekette on September 17, 2008 – 4:09 pmPosted in PHP | 2 Comments »
If you are using PHP and you would like a quick “Last Updated”line to be on the page, just place the following script in your html:
<?php date_default_timezone_set(”EST”); echo date (”Y-m-j h:i:s A (T)”, getlastmod()); ?>
The result will look like:
2008-09-11 07:37:23 PM (EST)
Or, if the command with the default time zone in it does not work, this one should do the same:
<?php echo date (”Y-m-j h:i:s A (T)”, getlastmod()); ?>
The result will look like:
2008-09-11 07:37:23 PM (EST)
Popularity: 8% [?]
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
§
Tags: last, PHP, script, updated
2 Comments »

(32 votes, average: 4.50 out of 5)

September 20th, 2008 at 10:58 pm
I wouldn’t use getlastmod because depending on how PHP and Apache were set up, it might not work correctly – see the PHP manual for details.
I’d use this instead:
echo date (”Y-m-j h:i:s A (T)”,filemtime($_SERVER['SCRIPT_FILENAME']));
September 22nd, 2008 at 2:09 am
Very nice Sarah, thank you.
I know that I had to check to make sure my apache mods were active for that, but this is a great tip to others who might not have the ability to change apache and php configs.