Forum Moderators: coopster

Message Too Old, No Replies

Change Modified date automatically

anyone know how?

         

ezyid

1:32 am on Nov 12, 2005 (gmt 0)

10+ Year Member



Hello all.
on my website my index page is php, and I update some of the content on a daily basis,
I use a news script, but this does not update the pages actual "Date Modified"

I want to be able to have this as always changing as my content is too, I dont want search engine spiders thinking that I do not update my content..

so rather than manually opening my pages then re-saving them is there any way to automatically do this?

Cheers.
Steve.

dreamcatcher

8:06 am on Nov 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi ezyid,

If you update the content daily, why not always have the current date displayed?

Last Updated: <?php echo date("j F Y");?>

Alternatively, if your news info is in a database, add another table to hold the last updated date and update it every time you update your content. Hope that makes sense.

dc

AlexK

3:01 pm on Nov 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It is important to realise that, unless the script sends the necessary Headers, there is *no* "Date Modified" on any dynamic page. Standard server config can only respond to If-Modified-Since for static pages.

I had reached the point where robots were taking more pages and bandwidth than humans, and wanted to reduce it. The Class on this page [webmasterworld.com] was the first step to achieve that. The second step was to have an "Updated" field in the database, which was then used during the Class init to produce a Modified date. The final step is routines in the Admin pages to update "Updated" if any relevant info changes.

ezyid

6:58 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



humm.. that all seems pretty far fetched for me..
all the script does is output the infomation as plane text on the site.

How would i update the headers also?

Chur.
Steve.

ergophobe

7:13 pm on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you want the simplest version..

header("Last—Modified:" . $date);

And $date is something you get using time() or filemtime() and format properly using date(). The final date format wants to look like this:

Wed, 15 Nov 1995 04:58:08 GMT

see
[w3.org...]

ezyid

8:05 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



im so... lost.

ezyid

8:35 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



alright a code i am using....

$today = date("D, j M Y G:i T");
header("Last—Modified:" . $today);

seems to work fine.. I think it does the job well.....

ezyid

8:58 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



oh no.. im having issues.. as my servers date is older than the pages date.. and this is sus.. is there anyway to sort this out or just leave it?

sunveria

11:00 am on Nov 22, 2005 (gmt 0)

10+ Year Member



use javascript instead of php

document.lastModified

sunveria

11:02 am on Nov 22, 2005 (gmt 0)

10+ Year Member



or you can use

filemtime

see php manual.

ergophobe

5:17 pm on Dec 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can only use filemtime() if there is a file that is relevant. In other words, if the page is in the DB, the filemtime() will be the modification date of the script, not the page, which probably bears no meaning.

dreamcatcher

6:36 pm on Dec 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There`s also the getlastmod() function:

[hk.php.net...]

dc

jatar_k

10:10 pm on Dec 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well if it is a single file serving everything you could just update that files last modified date everytime you add something to the db