/*************************************
Title:gbook
Version:1.43
Author:
Demo:
Download:
Website:http://www.gilsbus.ca
Short description: Slightly off-topic - displaying a 'modified on' date
*************************************/
I incorporated the guest book into my web-site
http://www.gilsbus.ca, Thank you.
In the footer of all pages on my site, I use the following javascript line to display the date/time that the file was created-
<script type="text/javascript">
document.writeln("Page updated - " + document.lastModified);</script>
On the guestbook pages rendered by PHP, this script will ALWAYS show that the file is newly created.
Is there a code I can include in footer.txt, or inside gbook.php itself which would display the 'modified on' date of the original gbook.php file and have it update automatically only when the original file is altered/amended?
To be consistent with the rest of my site, I would appreciate a solution which allows the code to be added to footer.txt.
My options as I see them
1. Discontinue all date/time references - delete code from footer.txt
2. Manually enter a date into the footer.txt file - Will not automatically update if file altered.
3. Get help from the forum to provide a workable solution. I consider myself a newbie to php.
Thanks in advance for your help.
How to display a 'modified on' date with php
Hello gildionne,
I use the following code on some of my pages to display the changed date (i translated from dutch to english for this post).
The code can be added to the footer.txt file.
It will show the changed date of the gbook.php file, not the date that the last message is added.
With date function:
With strftime function (for local day and month strings).
Local day and month strings are only returned if setlocal() is supported by the server:
Greetings,
Henrie
I use the following code on some of my pages to display the changed date (i translated from dutch to english for this post).
The code can be added to the footer.txt file.
It will show the changed date of the gbook.php file, not the date that the last message is added.
With date function:
Code: Select all
<p>Last modified:
<?php
// outputs e.g. 'Last modified: March 04 1998 20:43:59.'
echo date("F d Y H:i:s", getlastmod());
?>
</p>
Local day and month strings are only returned if setlocal() is supported by the server:
Code: Select all
<p>Last modified - :
<?php
// outputs e.g. 'Last modified: March 04 1998 20:43:59.'
//setlocale(LC_TIME, Dutch) for Windows server for dutch language
//setlocale(LC_TIME, nl_NL) for Linux server for dutch language
setlocale(LC_TIME, nl_NL);
echo strftime("%A %d %B %Y om %H:%M", getlastmod());
?>
</p>
Henrie
-
- Posts: 5
- Joined: Mon Oct 15, 2007 11:41 am