Get the timestamp of a file from a remote webserver
1<?php 2function GetRemoteLastModified($uri) { 3 // default 4 $unixtime = 0; 5 6 $fp = fopen( $uri, "r" ); 7 if (!$fp) {return;} 8 9 $MetaData = stream_get_meta_data( $fp );1011 foreach( $MetaData['wrapper_data'] as $response) {12 // case: redirection13 if( substr( strtolower($response), 0, 10 ) == 'location: ' )14 {15 $newUri = substr( $response, 10 );16 fclose( $fp );17 return GetRemoteLastModified( $newUri );18 }19 // case: last-modified20 elseif( substr( strtolower($response), 0, 15 ) == 'last-modified: ' )21 {22 $unixtime = strtotime( substr($response, 15) );23 break;24 }25 }26 fclose( $fp );27 return $unixtime;28}2930function showDayTime($theday, $full = false) {31 return (!$theday)?"None":date("m/d/" . (($full)?'Y':'y') . " h:ia", $theday);32}3334$stamp = GetRemoteLastModified('http://www.iloveinns.com/images/mastlogo.gif');35$stamp = showDayTime($stamp);36echo $stamp;37echo "\n";