I have a php code as shown below in which I want to display anything in between two calendar days of the week.
The values coming inside $data->{\"select_s
Here is the Example of displaying anything between time duration
Add any time of Toronto in start time and end time..you will be get output between this day and time duration in every week.
date_default_timezone_set('America/Toronto');
$now = new DateTime();
$date = $now->format('Y-m-d');
$time = $now->format('h:i A');
$dayname = strtolower(date('l', strtotime($date))); //it will give you today's day name
$start_day = "monday"; //lets consider your data will be come as startday="monday" from $data->{"select_start_day"};
$start_time = '07:50 AM'; //lets consider your data will be come as starttime="07:50 AM" from $data->{"start_time"};
$end_day = "tuesday"; //lets consider your data will be come as endday="monday" from $data->{"select_end_day"};
$end_time = '08:26 AM'; //lets consider your data will be come as endtime="08:26 AM" from $data->{"end_time"};
$todays_date_time = strtotime($dayname);
$start_day_time = strtotime($start_day);
$end_day_time = strtotime($end_day);
$timeconvert = strtotime($time);
$timeconvertstart = strtotime($start_time);
$timeconvertend = strtotime($end_time);
if($todays_date_time >= $start_day_time && $todays_date_time <= $end_day_time )
{
if ($timeconvert >= $timeconvertstart && $timeconvert <= $timeconvertend) {
echo "test";
}
}
I Hope this one is help you!