Hai All, In php how can i get last modified date of a give web page . I have tried to get last modified from the header but for some pages the server of that webpage doesn't returns lastmodified date.How can i do this with php ? Thanks in advance......
<?php // read the curent file $fp = fopen(__FILE__, "r"); // get file statistics $fstat = fstat($fp); // print the last modification time echo $fstat['mtime']; ?> PHP: OR <?php echo date("F d Y H:i:s.", getlastmod()); ?> PHP: OR <?php echo date ("F d Y H:i:s.", filemtime(__FILE__)); ?> PHP:
Thanks for replay.. In need to get lastmodified date for webpage for other websites in internet via http reponse or through other techniques..
I did it something like this: $conn = @fopen($httpAddress); $meta = stream_get_meta_data ($conn); Code (markup): This returns an array of the metadata, and Last Modified is in a subarray called "wrapper_data" with key 4: echo $meta['wrapper_data'][4]; Code (markup): This also contains the words "Last-Modified: ", so you can do: $dateForHumans = preg_replace('#Last-Modified: #', '', $meta['wrapper_data'][4]); $LastModified = strtotime($dateForHumans); Code (markup): Not sure if that is what you are looking for but works for me. Check the code, cos I copied it from some script of mine, the variable names might be mixed up or something.