Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function checkIfExist($fromTime, $toTime, $input) {
- $fromDateTime = DateTime::createFromFormat("!H:i", $fromTime);
- $toDateTime = DateTime::createFromFormat('!H:i', $toTime);
- $inputDateTime= DateTime::createFromFormat('!H:i', $input);
- if ($fromDateTime> $toDateTime) $toDateTime->modify('+1 day');
- return ($fromDateTime <= $inputDateTime&& $inputDateTime<= $toDateTime) || ($fromDateTime <= $inputDateTime->modify('+1 day') && $inputDateTime<= $toDateTime);
- }
- $result=checkIfExist("08:00","18:00","09:00");
- echo $result; // output 1 - true
- ?>
Advertisement
Add Comment
Please, Sign In to add comment