<?php date_default_timezone_set('America/Toronto'); $start_day = 'tue'; $start_time = 181300; $end_day = 'fri'; $end_time = 134500; $startDate = DateTime::createFromFormat ( 'D His', $start_day . ' '. $start_time); $endDate = DateTime::createFromFormat ( 'D His', $end_day . ' '. $end_time); $startHour = $startDate->format('G'); //24-hour format of an hour without leading zeros $startDay = $startDate->format('N'); //numeric representation of the day of the week $endHour = $endDate->format('G'); //24-hour format of an hour without leading zeros $endDay = $endDate->format('N'); //numeric representation of the day of the week //We Need to check the time is between Tuesday 6PM ( 2 and 18 for $startDay and $startHour respectively ) to Friday 6PM ( ( 5 and 18 for $endDay and $endHour respectively )) if ( $startDay >= 2 && $endDay <= 5 && $startHour >= 18 and $endHour <= 18 ) { echo 'Within Time Range'; } else { echo 'Outside Range'; }
You have javascript disabled. You will not be able to edit any code.