Forum Moderators: open
I'm not even sure if this request is resolvable with Javascript, but I am trying to have a piece of text within my HTML page automatically change its date when the file has been modified. Here is the URL to the page - you will see the bit of text towards the bottom "Last Updated..."
<snip>
Could some one please help me or point me in the right direction to achieve this?
Thanks
Kit
[edited by: eelixduppy at 5:21 am (utc) on Nov. 6, 2008]
[edit reason] no URLs, please [/edit]
<?php
$currFiles = get_included_files();
$thisPage = $currFiles[0];
$file = fopen($thisPage,"r");
$filestats = fstat($file);
echo "This page last modified on: ".(date("F d Y g:i:sa",$filestats[9]));
fclose($file);
?>
Put that on a .php page and upload to php enabled server and you are good to go.
If you want to change the date and time formatting, see w3schools php date() function reference here [w3schools.com]
You can also look up the fopen() and fstat() functions at w3schools Complete PHP Filesystem Reference [w3schools.com]
(The fstat() function returns a unix timestamp, which we then convert to a formatted date in the code above)
If you would just want the date (of the last modification) to show and not the time (of the last modification) just remove the part that reads g:i:sa as that part displays the hour, minute, second, am & pm