I have a code as shown below in which the values inside $start_day, $data->{"start_time"} and $end_day, $data->{"end_time"} is entered by user.
1. Start Day: $start_day
2. Start Time: $data->{"start_time"}
3. End Day: $end_day
4. End Time: $data->{"end_time"}
What I want to achieve through php is I want to display anything in between particular time duration.
I want to display something in between Start Day/Time and End Day/Time.
Let say suppose, $start_day
is mon
, $data->{"start_time"}
is 111300
.
$end_day
is sat
and $data->{"end_time"}
is 114500
date_default_timezone_set('America/Toronto');
$nowtime = (int)date('His');
$arradate = strtolower(date('D')); //extracting day of the week on the basis of timezone
$start_day=$data->{select_start_day}; // it can be `mon` or `tue` or `wed` or `thu` or `fri` or `sat` or `sun` depending on what is inside the JSON entered by the user.
$end_day=$data->{select_end_day}; // it can be `mon` or `tue` or `wed` or `thu` or `fri` or `sat` or `sun` depending on what is inside the JSON entered by the user.
The values inside all these variables is entered by user so in short user control all these times.
This is what I have tried and its not wroking for me.
if(($arradate >= $start_day && $nowtime>=$data->{"start_time"}) && ($arradate <= $end_day && $nowtime <= $data->{"end_time"})) {
echo "Hello World"; // I want Hello World to be displayed in between Friday 6pm and Tuesday 6pm
}
from How to display anything in php in between particular time duration?
No comments:
Post a Comment