How to divide time between particular minutes in php

Dear All,

I have Two fields like time-from and time-to and time-took for particular people so my job is

ex: time-from: 10:00:00
time-to : 1:20:10
time-took : 30 (min)

So i want to display the order like that:

10:00:00 , 10:30:00 11:00:00, 11:30:00, 12:00:00, 12:30:00, 1:00:00, 1:20:10

any suggestion please…?

thanks,

use the DatePeriod / DateInterval classes

https://www.php.net/manual/en/dateperiod.construct.php

How to pass variable instade of 30 Minutes…?

code: $time = strtotime(’+30 minutes’, $time);

didn’t you try anything? PT30M

i tried but it did’t work for me
This is my code…

            $start = $roww['time_from']; 
            $end = $roww['time_to']; 
            $time = strtotime($start);
            $timeStop = strtotime($end);
            while($time<$timeStop) {
               
               ?> 
               <div class="btn btn-default col-md-1" style=" padding: 11px;    margin: 10px;"><?php  
               echo $time11= date('H:i', $time);
                $time = strtotime('+30 minutes', $time);
                echo $time22=' - ' . date('H:i', $time);

So where’s the DatePeriod / DateInterval?

$divvalue=$roww[‘consulting_time_per_patient’];

there’s no usage of DatePeriod / DateInterval.

Sponsor our Newsletter | Privacy Policy | Terms of Service