moon14 Posted July 11, 2007 Share Posted July 11, 2007 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 Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 12, 2007 Share Posted July 12, 2007 It's best to use timestamps for this. Take a look at http://php.net/strtotime and http://php.net/time. Quote Link to comment Share on other sites More sharing options...
moon14 Posted July 12, 2007 Author Share Posted July 12, 2007 thanks ery much i will try it. but i unified the format and problem solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.