Latest Posts »
Latest Comments »
Popular Posts »

PHP Last Updated Script

Written by The Geekette on September 17, 2008 – 4:09 pm
Posted in PHP |


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)


No related posts.


§


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



Tags: , , ,

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 (21 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

Girl Geekette uses Thank Me Later

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.

Private

climacteric
climacteric
climacteric
climacteric