How to divide time between particular minutes in php

#1

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,

#2

use the DatePeriod / DateInterval classes

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

#3

How to pass variable instade of 30 Minutes…?

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

#4

didn’t you try anything? PT30M

#5

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);
#6

So where’s the DatePeriod / DateInterval?

#7

$divvalue=$roww[‘consulting_time_per_patient’];

#8

there’s no usage of DatePeriod / DateInterval.