Jump to content

[SOLVED] time comparison


moon14

Recommended Posts

hello

 

i have the following condition inside an if but something is wrong because i get different output from what i expect

i'm comparing a database table record fields with a user input datathe

 

the database table record fields representing a busy slot are saved into variables as follows:

$UnSlotDay: the day name

$UnSlotStartTime: busy slot start time

$UnSlotEndTime: busy slot end time

 

the user input for a new slot is:

$Day: the day name

$EndTime: new slot end time

$StartTime: new slot start time

 

if (($Day == $UnSlotDay) && (($EndTime<=$UnSlotStartTime) || ($StartTime>=$UnSlotEndTime)))
            echo "OK";
         else
            echo "Not OK";

 

if the busy slot is on Monday from 09:00:00 to 11:00:00, and the the new slot is also on Monday from 11:00 to 12:00

I get the message "Not OK".

 

Is it because the user input in hh:mm format and the busy slot is in hh:mm:ss ???

pls help me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.