0

Hello everyone i am working on a employee attendance system and i have the following issue.

I want to get the shift based on entry time for example if the worker is starting work betwen 5am and 10 am to be the shift 1 if it enters betwen 11 am and 3pm to be the shift 2 and if it enters betwen 7pm and 11pm to be the shift 3.

Here is what i tryied but i get stuck on getting the current time

$shift= 1;
        $stmp = time();
        //if($PR_Come <= $5:00 && $PR_Come>= $8:00) { $shift=1;}
        //if($PR_Come <= $11:00 && $PR_Come>= $16:00) { $shift=2;}
        //if($PR_Come <= $19:00 && $PR_Come>= $23:00) { $shift=3;}
        $PR_Come = date("Y-m-d H:i:s", $stmp);
        $PR_Year = date("Y",$stmp);
        $PR_Month = date("m",$stmp);
        $PR_Day = date("d",$stmp);
        $sqlcmd = "INSERT INTO $dbname.ppresence (PR_WorkerPTR, WORKER_Name, PR_Come, PR_Year, PR_Month, PR_Day, shift) VALUES "
        ."('".ppaddslashes($workerrow["WORKER_ID"])."', '".ppaddslashes($workerrow["WORKER_Name"])."', '".ppaddslashes($PR_Come)."','".ppaddslashes($PR_Year)."','".ppaddslashes($PR_Month)."','".ppaddslashes($PR_Day)."','".$shift."')";
        mysql_query($sqlcmd);

PS Sorry for my bad english. :)

0 Answers0