开发者

Appointment system, checking if person is availaible at particular time

i am working on an appointment system, the problem i am facing is in a function where i want to check if the person with whom someone wants to book an appointment is available at that time or not.

each person has fixed daily time slot for example 02:00:00 to 04:30:00 during which anyone can contact him/her, now when booking appointment, i wanna check if person is available at the time when someone is willing to book an appointment or not.

here is the code:

    $strtTime = 开发者_高级运维$PA[0]['starttime'];   //02:00:00
    $endTime = $PA[0]['endtime'];    //04:30:00        

    $expectedTime = date('g:i:s', strtotime($dteTime));   // $dteTime = 2010-12-31 02:30


    if($strtTime < $expectedTime && $endTime > $expectedTime) // the second condition is returning false
    {
        echo "PAA is available";
    }
    else
    {
        echo  "PAA is not available at that time slot.";
        exit();           
    }


date('g:i:s' return 2:30:00

04:30:00 > 2:30:00 is false, because of alpha sort ("04" is < "2")

So change date('g:i:s' to date('H:i:s'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜