3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date1 = new \DateTime('2006-04-12T12:30:00'); $date2 = new \DateTime('2006-04-14T11:30:00'); //determine what interval should be used - can change to weeks, months, etc $interval = new \DateInterval('PT1H'); //create periods every hour between the two dates $periods = new \DatePeriod($date1, $interval, $date2); //count the number of objects within the periods $hours = iterator_count($periods); echo $hours . ' hours';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vom6N
function name:  (null)
number of ops:  25
compiled vars:  !0 = $date1, !1 = $date2, !2 = $interval, !3 = $periods, !4 = $hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $5      'DateTime'
          1        SEND_VAL_EX                                              '2006-04-12T12%3A30%3A00'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $5
    4     4        NEW                                              $8      'DateTime'
          5        SEND_VAL_EX                                              '2006-04-14T11%3A30%3A00'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $8
    7     8        NEW                                              $11     'DateInterval'
          9        SEND_VAL_EX                                              'PT1H'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
   10    12        NEW                                              $14     'DatePeriod'
         13        SEND_VAR_EX                                              !0
         14        SEND_VAR_EX                                              !2
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !3, $14
   13    18        INIT_FCALL                                               'iterator_count'
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                         $17     
         21        ASSIGN                                                   !4, $17
   14    22        CONCAT                                           ~19     !4, '+hours'
         23        ECHO                                                     ~19
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
203.76 ms | 1395 KiB | 15 Q