3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDiffInMinutes($startTime, $endTime) { $diff = $startTime->diff($endTime); return round(1440 * $diff->d + 60 * $diff->h + $diff->i + 1/60 * $diff->s); } function getMinutesPerDay($startTime, $endTime) { $output = []; $startDate = $startTime->setTime(0, 0, 0); $endDate = $endTime->setTime(23, 59, 59); $oneDay = new DateInterval('P1D'); $period = new DatePeriod($startDate, $oneDay, $endDate); foreach ($period as $date) { $start = max($startTime, $date); $end = min($endTime, $date->add($oneDay)); $output[$date->format('Y-m-d')] = getDiffInMinutes($start, $end); } return $output; } $startTime = new DateTimeImmutable("2023-08-05 14:45:05"); $endTime = new DateTimeImmutable("2023-08-09 13:00:14"); print_r(getMinutesPerDay($startTime, $endTime));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Af18
function name:  (null)
number of ops:  16
compiled vars:  !0 = $startTime, !1 = $endTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'DateTimeImmutable'
          1        SEND_VAL_EX                                              '2023-08-05+14%3A45%3A05'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   26     4        NEW                                              $5      'DateTimeImmutable'
          5        SEND_VAL_EX                                              '2023-08-09+13%3A00%3A14'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   28     8        INIT_FCALL                                               'print_r'
          9        INIT_FCALL                                               'getminutesperday'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function getdiffinminutes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5Af18
function name:  getDiffInMinutes
number of ops:  21
compiled vars:  !0 = $startTime, !1 = $endTime, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_METHOD_CALL                                         !0, 'diff'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !2, $3
    6     6        INIT_FCALL                                               'round'
          7        FETCH_OBJ_R                                      ~5      !2, 'd'
          8        MUL                                              ~6      ~5, 1440
          9        FETCH_OBJ_R                                      ~7      !2, 'h'
         10        MUL                                              ~8      ~7, 60
         11        ADD                                              ~9      ~6, ~8
         12        FETCH_OBJ_R                                      ~10     !2, 'i'
         13        ADD                                              ~11     ~9, ~10
         14        FETCH_OBJ_R                                      ~12     !2, 's'
         15        MUL                                              ~13     ~12, 0.0166667
         16        ADD                                              ~14     ~11, ~13
         17        SEND_VAL                                                 ~14
         18        DO_ICALL                                         $15     
         19      > RETURN                                                   $15
    7    20*     > RETURN                                                   null

End of function getdiffinminutes

Function getminutesperday:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 50
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 50
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
filename:       /in/5Af18
function name:  getMinutesPerDay
number of ops:  53
compiled vars:  !0 = $startTime, !1 = $endTime, !2 = $output, !3 = $startDate, !4 = $endDate, !5 = $oneDay, !6 = $period, !7 = $date, !8 = $start, !9 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ASSIGN                                                   !2, <array>
   13     3        INIT_METHOD_CALL                                         !0, 'setTime'
          4        SEND_VAL_EX                                              0
          5        SEND_VAL_EX                                              0
          6        SEND_VAL_EX                                              0
          7        DO_FCALL                                      0  $11     
          8        ASSIGN                                                   !3, $11
   14     9        INIT_METHOD_CALL                                         !1, 'setTime'
         10        SEND_VAL_EX                                              23
         11        SEND_VAL_EX                                              59
         12        SEND_VAL_EX                                              59
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !4, $13
   15    15        NEW                                              $15     'DateInterval'
         16        SEND_VAL_EX                                              'P1D'
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !5, $15
   16    19        NEW                                              $18     'DatePeriod'
         20        SEND_VAR_EX                                              !3
         21        SEND_VAR_EX                                              !5
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !6, $18
   17    25      > FE_RESET_R                                       $21     !6, ->50
         26    > > FE_FETCH_R                                               $21, !7, ->50
   18    27    >   INIT_FCALL                                               'max'
         28        SEND_VAR                                                 !0
         29        SEND_VAR                                                 !7
         30        DO_ICALL                                         $22     
         31        ASSIGN                                                   !8, $22
   19    32        INIT_FCALL                                               'min'
         33        SEND_VAR                                                 !1
         34        INIT_METHOD_CALL                                         !7, 'add'
         35        SEND_VAR_EX                                              !5
         36        DO_FCALL                                      0  $24     
         37        SEND_VAR                                                 $24
         38        DO_ICALL                                         $25     
         39        ASSIGN                                                   !9, $25
   20    40        INIT_METHOD_CALL                                         !7, 'format'
         41        SEND_VAL_EX                                              'Y-m-d'
         42        DO_FCALL                                      0  $27     
         43        INIT_FCALL                                               'getdiffinminutes'
         44        SEND_VAR                                                 !8
         45        SEND_VAR                                                 !9
         46        DO_FCALL                                      0  $29     
         47        ASSIGN_DIM                                               !2, $27
         48        OP_DATA                                                  $29
   17    49      > JMP                                                      ->26
         50    >   FE_FREE                                                  $21
   22    51      > RETURN                                                   !2
   23    52*     > RETURN                                                   null

End of function getminutesperday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.53 ms | 1025 KiB | 19 Q