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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prepster
Forum Newbie
Posts: 3
Joined: Fri Feb 01, 2008 7:49 pm

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

Post 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?? :?:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

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

Post 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));
 
Post Reply