Connecting Tech Pros Worldwide Help | Site Map

To get last modified date of website

rishidadhich's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 9
#1: Feb 27 '07
hi all,

I want to get the last modified date of a website,
but I am completely clueless how to do it.
Is any one got any idea how to do it..

thanx in advance....
Familiar Sight
 
Join Date: Nov 2006
Posts: 161
#2: Feb 28 '07

re: To get last modified date of website


Well a quick google revealed

echo date("m/d/Y",filemtime("filename.php"));

Format it how you like...
Familiar Sight
 
Join Date: Nov 2006
Posts: 161
#3: Feb 28 '07

re: To get last modified date of website


Or even better (I think) from the php manual

<?php
// outputs e.g. 'Last modified: March 04 1998 20:43:59.'
echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());
?>
rishidadhich's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 9
#4: Feb 28 '07

re: To get last modified date of website


thanx Beary,
but problem is not solved yet.
I wanna write a script which will generate the last modified date of any outside url say www.example.com etc.
your code will generate last modified date of current file only.
Familiar Sight
 
Join Date: Nov 2006
Posts: 161
#5: Feb 28 '07

re: To get last modified date of website


Quote:

Originally Posted by rishidadhich

thanx Beary,
but problem is not solved yet.
I wanna write a script which will generate the last modified date of any outside url say www.example.com etc.
your code will generate last modified date of current file only.


Aah. Sorry I didn't see that clearly. I found this page:

http://fundisom.com/phparadise/php/file_handling/remote_last_modified

which says it works. I tried it but the date kept saying January 1, 1970 for any file. But apparently it's exactly what you want. If I find something better I'll post. Otherwise, please let know that it works.
rishidadhich's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 9
#6: Mar 1 '07

re: To get last modified date of website


no its not working dear,
as you also noticed that its showing again and again January 1, 1970
b'coz its a unix timestamp, starting date of unix, so by default its showing that date.
yaa if u find anything please let me know..

thanx



Quote:

Originally Posted by beary

Aah. Sorry I didn't see that clearly. I found this page:

http://fundisom.com/phparadise/php/file_handling/remote_last_modified

which says it works. I tried it but the date kept saying January 1, 1970 for any file. But apparently it's exactly what you want. If I find something better I'll post. Otherwise, please let know that it works.

Familiar Sight
 
Join Date: Nov 2006
Posts: 161
#7: Mar 1 '07

re: To get last modified date of website


Quote:

Originally Posted by rishidadhich

no its not working dear,

dear????????????
rishidadhich's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 9
#8: Mar 1 '07

re: To get last modified date of website


ignore the words which u can't understand,
and try to be on the issue, which is how to get modified date of website.
well thanx for your efforts.
but i had solved the problem..

thanx again.
Familiar Sight
 
Join Date: Nov 2006
Posts: 161
#9: Mar 1 '07

re: To get last modified date of website


Quote:

Originally Posted by rishidadhich

ignore the words which u can't understand,
and try to be on the issue, which is how to get modified date of website.
well thanx for your efforts.
but i had solved the problem..

thanx again.

So are you going to post your solution here? No-one else answered, which I assume means no-one else knew. Share the solution...

And by the way, perhaps next time you could leave the attitude at the door. You come to a forum to get help; stop acting like you're way above everyone else. I understood the words no problem; it was the tone that was off.

<mental note>ignore future posts from rishidadhich</mental note>
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#10: Mar 2 '07

re: To get last modified date of website


Now guys that will be enough of that for now. No need to ignore each other's posts. I'm sure we all never intend to offend anyone. Unfortunately it just happens sometimes and whenever we dicover it we should be able to take back our offenses.

Now about the scipt

[HTML]
Last modified: " . date ("F d Y H:i:s.", getlastmod());

[/HTML]
I just wanted to know how one passes the name of the file to check the last modified date. I mean I understsood


[PHP] echo date("m/d/Y",filemtime("filename.php"));
[/PHP]

where I can see the filename passed as argument.
rishidadhich's Avatar
Newbie
 
Join Date: Feb 2007
Posts: 9
#11: Mar 2 '07

re: To get last modified date of website


Quote:

Originally Posted by r035198x

Now guys that will be enough of that for now. No need to ignore each other's posts. I'm sure we all never intend to offend anyone. Unfortunately it just happens sometimes and whenever we dicover it we should be able to take back our offenses.

Now about the scipt

[HTML]
Last modified: " . date ("F d Y H:i:s.", getlastmod());

[/HTML]
I just wanted to know how one passes the name of the file to check the last modified date. I mean I understsood


[PHP] echo date("m/d/Y",filemtime("filename.php"));
[/PHP]

where I can see the filename passed as argument.


hi,
sorry if my words hurts any on.
ok leave it.........
now the code is..
[PHP]
$url = 'http://www.rediff.com/';

echo ("<pre>");
$a= (get_headers($url,1));

$c =$a['Last-Modified'];
echo ("<p>");
print_r ($c);

[/PHP]
It's just extracting last modified date from the header part.
If the website is not providing the last modified date then it wont work.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#12: Mar 2 '07

re: To get last modified date of website


Quote:

Originally Posted by rishidadhich

hi,
sorry if my words hurts any on.
ok leave it.........
now the code is..
[PHP]
$url = 'http://www.rediff.com/';

echo ("<pre>");
$a= (get_headers($url,1));

$c =$a['Last-Modified'];
echo ("<p>");
print_r ($c);

[/PHP]
It's just extracting last modified date from the header part.
If the website is not providing the last modified date then it wont work.

Thanks a lot. Handy script.
zorgi's Avatar
Member
 
Join Date: Mar 2008
Location: here
Posts: 107
#13: Mar 10 '08

re: To get last modified date of website


Thanks rishidadhich

It works if ['Last-Modified'] is within headers. I tested the script and found that 8 out of 10 times ['Last-Modified'] is not there. Any ideas anyone?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#14: Mar 10 '08

re: To get last modified date of website


Quote:

Originally Posted by r035198x

[HTML]
Last modified: " . date ("F d Y H:i:s.", getlastmod());

[/HTML]
I just wanted to know how one passes the name of the file to check the last modified date.

you don't pass any arguments with getlastmod
Quote:

Originally Posted by php.net

getlastmod( void )

It returns the last mod of the current file. i.e. the file that this function is present in.

regards
Newbie
 
Join Date: Oct 2009
Location: New Delhi, India
Posts: 2
#15: 4 Weeks Ago

re: To get last modified date of website


Quote:

Originally Posted by zorgi View Post

Thanks rishidadhich

It works if ['Last-Modified'] is within headers. I tested the script and found that 8 out of 10 times ['Last-Modified'] is not there. Any ideas anyone?

Any idea about this. For me 10 out of 10 times ['Last-Modified'] is not there.
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,094
#16: 4 Weeks Ago

re: To get last modified date of website


This is not possible to my knowledge. You send a request and the web server sends you a file. Those odd headers can't be counted on.

curious,

why do people want the modified date of remote websites?

what are you checking up on? How reliable is it when the website host moves or copies the file (without altering the contents) and the date is reset. The data the page gives you has not been "updated", even though if you were to get the new date.




Dan
Newbie
 
Join Date: Oct 2009
Location: New Delhi, India
Posts: 2
#17: 4 Weeks Ago

re: To get last modified date of website


I have checked SEO posts where people say search engine spiders checks Last modified date header to know whether contents are updated or not. Even in tools like web ceo they have a field last updated. I never get this values for my sites.
Reply