I have a program I am working on. Basically it dedupes records in our database. Users can log online and work from there.
I have an interface were users can see what files are available in their directory on the server that need to be deduped.
it calls a function that adds the files in the directory with the date it was uploaded... supposedly. (I didnt write original code)... anyway I digress...
here is the function
function outputScrub(){
$dir = "tmp/steven/reg/";
//Open a known directory, and proceed to read its contents
if (is_dir($dir)){
if ($dh = opendir($dir)){
while(($file = readdir($dh)) !== false){
if($file != '..' && !is_dir($dir.$file)){
$file2=str_replace(" ","%20",$file);
$arr=explode("_",$file);
$tm=$arr[0];
$arr=explode(".",$tm);
$tm=$arr[0];
$d=date("m-d-Y",$tm);
$path=$dir.$file2;
$row = "0";
echo ("Path to file".$path);
$fp = fopen("$path", "r");
while ($data = fgetcsv($fp, 4096, ",")){
$num = count($data);
$num++;
$row++;
}//end while loop
echo "<br>Number of fields in file: ".$num."<br>";
$counter = sizeof($data);
echo "<br><a href=$dir".$file2.">$file</a> DATE: $d |";
echo"<br>Number of Records in the file: ".$row;
}//end if
}//end while loop
closedir($dh);
}//end if
}//end if
}
this code will output:
SX106clean.txt DATE: 12-31-1969 |
for some reason it always comes up with a year of 1969. what is causing this? How can I fix it to display the date the file was uploaded?
Thanks