Latest Posts »
Latest Comments »
Popular Posts »

PHP Last Updated Script

Written by The Geekette on September 17, 2008 – 4:09 pm
Posted 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.


§


Email This Post Email This Post | Print This Post Print This Post |



Tags: , , ,
2 Comments »

2 Comments to “PHP Last Updated Script”

  1. Sarah (2 comments) Says:

    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']));

  2. The Geekette (22 comments) Says:

    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.

Leave a Comment

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. Please understand with hundreds of SPAM comments, it takes a while to sort through to approve the good comments. Sometimes, by accident, some good comments accidentally get marked as spam. Please let us know if your comment did not get posted. Also, if your comment has a link to it or anything else in it that would make it seem like spam, it will be deleted. So please post a real comment and not one that is only made to link to a site only. Otherwise, it could get deleted.