Add range in PHP scheduling system slots

71
April 05, 2021, at 10:20 PM

Helo! I am a beginner in programming and if anyone can help me change a code snippet I would appreciate it. I have a scheduling system with time slots, where the slots are generated from variables with the start date until the end date. I want to add a period between the start and end time, where nothing can be scheduled, for example, from 12:00 to 13:00, however, I don't know how to do it. Follow the code below:

$duration = 15;
$cleanup = 0;
$start = "08:00";
$end = "18:00";
function timeslots($duration, $cleanup, $start, $end){
    $start = new DateTime($start);
    $end = new DateTime($end);
    $interval = new DateInterval("PT".$duration."M");
    $cleanupInterval = new DateInterval("PT".$cleanup."M");
    $slots = array();
    
    for($intStart = $start; $intStart<$end; $intStart->add($interval)->add($cleanupInterval)){
        $endPeriod = clone $intStart;
        $endPeriod->add($interval);
        if($endPeriod>$end){
            break;
        }
        
        $slots[] = $intStart->format("H:iA")." - ". $endPeriod->format("H:iA");
        
    }
    
    return $slots;
}
Answer 1

You can refer to this https://www.codexworld.com/create-time-range-array-php/ where in you can have an array and you get the indexes for your start and end time and then you can avoid all indexes between the start_index and end_index.

READ ALSO
how to send second result in expressjs

how to send second result in expressjs

i want to make Whatsapp bot and integrated to my websitethe system send the qr and users scan it through my website and after users scan and connected i want to send a message to the users it had been connected in the same page

62
Json return [object, Object]

Json return [object, Object]

I'm trying to display json data to html tableThis is my code:

30
how to round the yaxis using matplotlib.ticker in python

how to round the yaxis using matplotlib.ticker in python

I am trying to adjust the y-axis using matplotlibticker

74