On Feb 17, 2008 12:53 AM, Johny Burns <contactus@xxxxxxxxxxxxxxxx> wrote: > I am having fields in my table where I put times like 4:30pm in string > format > > Can anybody help with function which helps detect. > Is it the current time between those fields? > > function checkinzone($time1,$time2):boolean > > Has to verify does the current time is in those 2 variables. > > Thank you for your help. My ability with time and date funtions in PHP are > not that great convert $time1 and $time2 to unix timestamps; from there its a matter of basic logic; something like this (vaguely) function isTimeBetween($time1, $time2) { if(!($lowerBound = date('U', $time1)) { return false; } if(!($upperBound = date('U', $time2)) { return false; } $curTime = mktime(); if($curTime > $lowerBound && $curTime < $upperBound) { return true; } else { return false; } } note; $time1 and $time2 will have to unix timestamps; this function will verify that by passing them through the date() function. http://www.php.net/manual/en/function.date.php if you want something a little more flexible; check out; strtotime(); http://www.php.net/manual/en/function.strtotime.php and also, the DateTime class will make for good reading ;) http://www.php.net/manual/en/function.date-create.php -nathan