This is very specific to my own purpose but it might help:
PHP Code:
$filename = __FILE__;
function last_updated($filename)
{
// Display the date
// eg. Jan 25 2004
$todaydiff = "5";//server-to-GMT time
$timeadjust = ($todaydiff * 60 * 60);
$gmt_today_date = date("M d Y",time() + $timeadjust);
$yestdiff = "19"; //24hrs - server-to-GMT time = 19hrs
$timeadjust = ($yestdiff * 60 * 60);
$gmt_yest_date = date("M d Y",time() - $timeadjust);
$last_modified_file = filemtime($filename);
$last_modified_file_day = gmdate("M d Y", $last_modified_file);
$last_modified_file_time = gmdate("g:ia", $last_modified_file);
if ($last_modified_file_day == $gmt_today_date){
$last_modified = 'Today ' . $last_modified_file_time;
}
elseif ($last_modified_file_day == $gmt_yest_date){
$last_modified = 'Yesterday ' . $last_modified_file_time;
}
else{
$last_modified = $last_modified_file_day;
}
return $last_modified;
}
This takes the current page's filename and finds the local time. Depending on when the file was last updated it outputs, today, yesterday or if more than 3 days old the date.
It takes into consideration the time difference between local and server times.
This script prob has a few faults etc but it works for me (feel free to point out any of these faults).
What you could do is on the page you updated make $filename a global variable. So on every page you update:
//index page
$filename = index.php
//events page
$filename = events.php
This will use at filename as the input and return the last updated time.
To use the output from the code on your include page do:
PHP Code:
<?php echo("<b>Last Updated: " . $last_modified . "</b>");?>
Bookmarks