liamallan
04-21-2011, 07:48 AM
hi, im trying to get the 'last modified' time of a file on my server, im currently using the filetime() function to try accomplish this. however, when i run the script, i get met with this error:
Warning: filemtime() [function.filemtime]: stat failed for http://mydomain.co.cc/path/to/file/filetogetsizeof.zip in /home/shifty/public_html/modules/downloads/downloads.php on line 144
this is the script i am running to try get the last modified time of the file:
$filelocation = ''.uhome().'/modules/downloads/downloads/'.$info['download_file'].'';
$last_modified = time() - filemtime($filelocation);
if(round($last_modified/(24*3600)) >= 1){ // over a day?
$last_modified /= (24*3600);
if(round($last_modified) > 6){ // at least a week?
$last_modified /= 7;
if(round($last_modified) > 3){ // .. months?
$last_modified /= 4;
if(round($last_modified) > 11){
$last_modified /= 12;
$output = round($last_modified).' years';
}
else{
$output = '~'.round($last_modified).' months';
}
}
else{
$output = round($last_modified).' weeks';
}
}
else{
$output = round($last_modified).' days';
}
}
else if(round($last_modified/3600) >= 1){ // At least one hour ago
$output = round($last_modified/3600).' hours';
}
else{
if($last_modified/60 < 1){ // barely a few secs ago
$output = $last_modified.' seconds';
}
else{
$output = round($last_modified/60).' minutes';
}
}
if(preg_match('/^1[^0-9]/', $output)){
$output = substr($output, 0, -1);
}
section_content(''.$output.' ago');
for every different file, i get the same output: 45 years ago
if anyone could give me any advice, or notice where im going wrong, i would be most greatful
Warning: filemtime() [function.filemtime]: stat failed for http://mydomain.co.cc/path/to/file/filetogetsizeof.zip in /home/shifty/public_html/modules/downloads/downloads.php on line 144
this is the script i am running to try get the last modified time of the file:
$filelocation = ''.uhome().'/modules/downloads/downloads/'.$info['download_file'].'';
$last_modified = time() - filemtime($filelocation);
if(round($last_modified/(24*3600)) >= 1){ // over a day?
$last_modified /= (24*3600);
if(round($last_modified) > 6){ // at least a week?
$last_modified /= 7;
if(round($last_modified) > 3){ // .. months?
$last_modified /= 4;
if(round($last_modified) > 11){
$last_modified /= 12;
$output = round($last_modified).' years';
}
else{
$output = '~'.round($last_modified).' months';
}
}
else{
$output = round($last_modified).' weeks';
}
}
else{
$output = round($last_modified).' days';
}
}
else if(round($last_modified/3600) >= 1){ // At least one hour ago
$output = round($last_modified/3600).' hours';
}
else{
if($last_modified/60 < 1){ // barely a few secs ago
$output = $last_modified.' seconds';
}
else{
$output = round($last_modified/60).' minutes';
}
}
if(preg_match('/^1[^0-9]/', $output)){
$output = substr($output, 0, -1);
}
section_content(''.$output.' ago');
for every different file, i get the same output: 45 years ago
if anyone could give me any advice, or notice where im going wrong, i would be most greatful