datetime - PHP function to check time between the given range? -
i using php's date functions in project , want check weather given date-time lies between given range of date-time.i.e example if current date-time 2010-11-16 12:25:00 pm , want check if time between 2010-11-16 09:00:00 06:00:00 pm. in above case true , if time not in between range should return false. there inbuild php function check or have write new function??
simply use strtotime convert 2 times unix timestamps:
a sample function like:
function dateisbetween($from, $to, $date = 'now') { $date = is_int($date) ? $date : strtotime($date); // convert non timestamps $from = is_int($from) ? $from : strtotime($from); // .. $to = is_int($to) ? $to : strtotime($to); // .. return ($date > $from) && ($date < $to); // parens clarity }
Comments
Post a Comment