Date Modified

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Date Modified

Post by Vegan »

I recall from long ago you could use a Front Page Extension to show the date that the page was last modified. If that possible with PHP to determine this and then "echo" the result as part of a footer document.

Thanks in advance
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Date Modified

Post by Darhazer »

If it is a static page, you can use the filemtime function. You can even output a javascript, which renders the document.latModified property.
But if this is a dynamic script, for exampe a database driven application, you have to get the data of last entry in the database and to output it. And it's more important to send it as an HTTP header, then to output it in the footer.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Date Modified

Post by requinix »

By the way, for static pages

Code: Select all

filemtime(__FILE__) // file containing this code
filemtime($_SERVER["SCRIPT_FILENAME"]) // file originally requested
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Date Modified

Post by Vegan »

<script type="text/javascript">
// This does not remain a constant with each refresh
var date
date=document.lastModified
document.write("Last Modified on "+date)
</script>

So I need some PHP to replace this, somebody?

The above probably is more suitable to HTML rather than PHP based ones. Have not tried that way.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Date Modified

Post by Vegan »

Found something after sifting through some crud.

Code: Select all

<?php
// outputs e.g. 'Last modified: March 04 1998 20:43:59.'
echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());
?>

This works fine, which is what my goal was.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply