3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testCases = [ ['2017-06-30 15:00:00', '2017-06-30 15:01:00'], ['2017-06-30 15:00:00', '2017-06-30 15:15:00'], ['2017-06-30 15:00:00', '2017-06-30 15:16:34'], ['2017-06-30 15:00:00', '2017-07-01 12:48:34'], ['2017-06-30 16:18:45', '2017-07-01 11:54:34'], ]; foreach ($testCases as $test) { list($inicio, $encerramento) = $test; $inicio = DateTime::createFromFormat('Y-m-d H:i:s', $inicio); $encerramento = DateTime::createFromFormat('Y-m-d H:i:s', $encerramento); $duracao = $inicio->diff($encerramento, true); var_dump($duracao); var_dump(join(':', [ str_pad($duracao->days*24 + $duracao->h, 2, STR_PAD_RIGHT, '0'), str_pad($duracao->i, 2, STR_PAD_RIGHT, '0'), str_pad($duracao->s, 2, STR_PAD_RIGHT, '0'), ])); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 62
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 62
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
filename:       /in/ritN8
function name:  (null)
number of ops:  64
compiled vars:  !0 = $testCases, !1 = $test, !2 = $inicio, !3 = $encerramento, !4 = $duracao
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1      > FE_RESET_R                                       $6      !0, ->62
          2    > > FE_FETCH_R                                               $6, !1, ->62
   12     3    >   QM_ASSIGN                                        ~7      !1
          4        FETCH_LIST_R                                     $8      ~7, 0
          5        ASSIGN                                                   !2, $8
          6        FETCH_LIST_R                                     $10     ~7, 1
          7        ASSIGN                                                   !3, $10
          8        FREE                                                     ~7
   14     9        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         10        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         11        SEND_VAR                                                 !2
         12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !2, $12
   15    14        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         15        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         16        SEND_VAR                                                 !3
         17        DO_FCALL                                      0  $14     
         18        ASSIGN                                                   !3, $14
   16    19        INIT_METHOD_CALL                                         !2, 'diff'
         20        SEND_VAR_EX                                              !3
         21        SEND_VAL_EX                                              <true>
         22        DO_FCALL                                      0  $16     
         23        ASSIGN                                                   !4, $16
   17    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                                 
   18    27        INIT_FCALL                                               'var_dump'
         28        INIT_FCALL                                               'join'
         29        SEND_VAL                                                 '%3A'
   19    30        INIT_FCALL                                               'str_pad'
         31        FETCH_OBJ_R                                      ~19     !4, 'days'
         32        MUL                                              ~20     ~19, 24
         33        FETCH_OBJ_R                                      ~21     !4, 'h'
         34        ADD                                              ~22     ~20, ~21
         35        SEND_VAL                                                 ~22
         36        SEND_VAL                                                 2
         37        SEND_VAL                                                 1
         38        SEND_VAL                                                 '0'
         39        DO_ICALL                                         $23     
         40        INIT_ARRAY                                       ~24     $23
   20    41        INIT_FCALL                                               'str_pad'
         42        FETCH_OBJ_R                                      ~25     !4, 'i'
         43        SEND_VAL                                                 ~25
         44        SEND_VAL                                                 2
         45        SEND_VAL                                                 1
         46        SEND_VAL                                                 '0'
         47        DO_ICALL                                         $26     
         48        ADD_ARRAY_ELEMENT                                ~24     $26
   21    49        INIT_FCALL                                               'str_pad'
         50        FETCH_OBJ_R                                      ~27     !4, 's'
         51        SEND_VAL                                                 ~27
         52        SEND_VAL                                                 2
         53        SEND_VAL                                                 1
         54        SEND_VAL                                                 '0'
         55        DO_ICALL                                         $28     
         56        ADD_ARRAY_ELEMENT                                ~24     $28
         57        SEND_VAL                                                 ~24
         58        DO_ICALL                                         $29     
         59        SEND_VAR                                                 $29
         60        DO_ICALL                                                 
   11    61      > JMP                                                      ->2
         62    >   FE_FREE                                                  $6
   23    63      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.69 ms | 1400 KiB | 19 Q