Posted by ELINTPimp on 08/03/07 14:54
> > You can't compare times as strings and expect it to work. You need to
> > first convert them to a numeric value, i.e. unixtime format.
>
> Times in H:i:s format can be perfectly compared as strings.
>
yup, currently doing it in a small project I'm working on.
your function:
function checkTime($time1,$time2){
$nowTime=date("H:i:s");
//do validation on $time1 and $time2 to ensure H:i:s format
if( $time1>$nowTime && $time2<$nowTime) {
return true;
}
else {
return false;
}
} // end checkTime
your function, which stripped of validation and exception handling,
looks like it should work (so long as $time1 and $time2 are in H:i:s
format. What's the problem?
[Back to original message]
|