To get last modified date of website

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rishidadhich
    New Member
    • Feb 2007
    • 9

    To get last modified date of website

    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....
  • beary
    New Member
    • Nov 2006
    • 170

    #2
    Well a quick google revealed

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

    Format it how you like...

    Comment

    • beary
      New Member
      • Nov 2006
      • 170

      #3
      Or even better (I think) from the php manual

      Code:
      <?php
      // outputs e.g. 'Last modified: March 04 1998 20:43:59.'
      echo "Last modified: " . date ("F d Y H:i:s.", getlastmod());
      ?>
      Last edited by acoder; May 7 '13, 12:18 PM.

      Comment

      • rishidadhich
        New Member
        • Feb 2007
        • 9

        #4
        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.

        Comment

        • beary
          New Member
          • Nov 2006
          • 170

          #5
          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_mod ified

          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.

          Comment

          • rishidadhich
            New Member
            • Feb 2007
            • 9

            #6
            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



            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_mod ified

            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.

            Comment

            • beary
              New Member
              • Nov 2006
              • 170

              #7
              Originally posted by rishidadhich
              no its not working dear,
              dear??????????? ?

              Comment

              • rishidadhich
                New Member
                • Feb 2007
                • 9

                #8
                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.

                Comment

                • beary
                  New Member
                  • Nov 2006
                  • 170

                  #9
                  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>

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    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

                    Code:
                     
                    Last modified: " . date ("F d Y H:i:s.", getlastmod());
                    I just wanted to know how one passes the name of the file to check the last modified date. I mean I understsood


                    Code:
                     echo date("m/d/Y",filemtime("filename.php"));
                    where I can see the filename passed as argument.
                    Last edited by acoder; May 7 '13, 12:20 PM.

                    Comment

                    • rishidadhich
                      New Member
                      • Feb 2007
                      • 9

                      #11
                      hi,
                      sorry if my words hurts any on.
                      ok leave it.........
                      now the code is..
                      Code:
                      					$url = 'http://www.rediff.com/';
                      
                      					echo ("<pre>");
                      					$a= (get_headers($url,1));
                      
                      					 $c =$a['Last-Modified'];
                      					 echo ("<p>");
                      					 print_r ($c);
                      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.
                      Last edited by acoder; May 7 '13, 12:21 PM.

                      Comment

                      • r035198x
                        MVP
                        • Sep 2006
                        • 13225

                        #12
                        Thanks a lot. Handy script.
                        Last edited by acoder; May 7 '13, 12:21 PM.

                        Comment

                        • zorgi
                          Recognized Expert Contributor
                          • Mar 2008
                          • 431

                          #13
                          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?

                          Comment

                          • Markus
                            Recognized Expert Expert
                            • Jun 2007
                            • 6092

                            #14
                            Originally posted by r035198x
                            Code:
                             
                            Last modified: " . date ("F d Y H:i:s.", getlastmod());
                            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
                            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
                            Last edited by acoder; May 7 '13, 12:22 PM.

                            Comment

                            • t2india
                              New Member
                              • Oct 2009
                              • 2

                              #15
                              Originally posted by zorgi
                              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.
                              Last edited by acoder; May 7 '13, 12:22 PM.

                              Comment

                              Working...