I have a start time and an end time in a human readable format of days hours and Am or PM that is from a user generated form that is stored in a database.
What I would like to be able to do is when the time is over the start time but not over the end time, execute the code in the current day.
Now so far I have successfully done this but I am having trouble with the AM and PM times. Here is the code so far...
Code: Select all
$timezone = '-7200'; /// the time difference to the user from the server
$time = time()-$timezone;
///converting to 24 hour time
if($start_a == PM){ $start_hour = ($start_hour+12); }
//getting the start time into the unix timestamp format
$start_time = mktime ($start_hour,$start_min,0,date("m",time()- $timezone),date("d",time()- $timezone),date("y",time()- $timezone));
//converting to 24 hour time
if($end_a == PM){ $end_hour = ($end_hour +12); }
//getting the end time into the unix timestamp format
$end_time = mktime ($end_hour,$end_min,0,date("m",time()- $timezone),date("d",time()- $timezone),date("y",time()- $timezone));
// if the current time is between start time and end time..
if($time > $start_time && $time < $end_time){
//do this code
echo "do this code";
}else{
//if time time dose not fall within the start and end times do this code
echo "It is not quite time yet to execute the code";
}