3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDiffInHours(\DateTime $earlierDate, \DateTime $laterDate) { $utc = new \DateTimeZone('UTC'); //First convert to UTC to avoid missing hours due to DST etc $earlierDate->setTimezone($utc); $laterDate->setTimezone($utc); $diff = $earlierDate->diff($laterDate); return 24 * $diff->days + $diff->h; } $hours = getDiffInHours(new \DateTime(), new \DateTime('+ 31 hours')); var_dump($hours);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M8lGt
function name:  (null)
number of ops:  14
compiled vars:  !0 = $hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                               'getdiffinhours'
          1        NEW                                              $1      'DateTime'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $1
          4        NEW                                              $3      'DateTime'
          5        SEND_VAL_EX                                              '%2B+31+hours'
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $3
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !0, $5
   12    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function getdiffinhours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M8lGt
function name:  getDiffInHours
number of ops:  22
compiled vars:  !0 = $earlierDate, !1 = $laterDate, !2 = $utc, !3 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        NEW                                              $4      'DateTimeZone'
          3        SEND_VAL_EX                                              'UTC'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $4
    6     6        INIT_METHOD_CALL                                         !0, 'setTimezone'
          7        SEND_VAR_EX                                              !2
          8        DO_FCALL                                      0          
    7     9        INIT_METHOD_CALL                                         !1, 'setTimezone'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
    8    12        INIT_METHOD_CALL                                         !0, 'diff'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !3, $9
    9    16        FETCH_OBJ_R                                      ~11     !3, 'days'
         17        MUL                                              ~12     ~11, 24
         18        FETCH_OBJ_R                                      ~13     !3, 'h'
         19        ADD                                              ~14     ~12, ~13
         20      > RETURN                                                   ~14
   10    21*     > RETURN                                                   null

End of function getdiffinhours

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.29 ms | 1399 KiB | 16 Q