Page 1 of 1

filmetime() returns 01/14/1970...

Posted: Wed Feb 13, 2008 1:18 pm
by prepster
In a file directory listing, the following code is returning false, or worse, 01/14/1970 not even 01/01/1970 (Unix Epoch time)

Code: Select all

$date = filemtime($dirStr."/".$file);
Within this script the other components, basename() an filesize() work fine:

Code: Select all

$name = basename($dirStr."/".$file);
 $size = filesize($dirStr."/".$file);
I also tried passing getlastmod() and it returns 12/31/1969.

I tried converting the unix time with

Code: Select all

$date = filemtime($dirStr."/".$file);
$normdate = date("m/d/Y", $date);
And this returns null -- nothing shows up.

Could anyone help me resolve this issue?? :?:

Re: filmetime() returns 01/14/1970...

Posted: Wed Feb 13, 2008 1:34 pm
by John Cartwright
As a sanity check, please run the following code directly before the filemtime() call

Code: Select all

echo 'Checking file: '; 
var_dump($dirStr."/".$file); 
echo '<br />';
echo 'File '. (file_exists($dirStr."/".$file) ? 'exists' : 'does not exist') .'<br />';
echo 'Filemtime: '. date('m-d-Y', filemtime($dirStr."/".$file));