3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*$a = '12:21'; $b = '17:00'; $c = '09:00'; $d = '13:53'; $t1 = convertToSeconds(getTimeDiff($a,$b)); echo "\n"; $t2 = convertToSeconds(getTimeDiff($c,$d)); echo "\n"; echo gmdate("H:i",$t1+$t2);*/ $d = 4371960; $h = int($d/3600); $m = int(($d%3600)/60); echo "son $h:$m"; function convertToSeconds($time){ $a = explode(":", $time); $hora = $a[0]; $min = $a[1]; return $hora*3600+$min*60; } function getTimeDiff($dtime,$atime){ $nextDay=$dtime>$atime?1:0; $dep=explode(':',$dtime); $arr=explode(':',$atime); $diff=abs(mktime($dep[0],$dep[1],0,date('n'),date('j'),date('y'))-mktime($arr[0],$arr[1],0,date('n'),date('j')+$nextDay,date('y'))); $hours=floor($diff/(60*60)); $mins=floor(($diff-($hours*60*60))/(60)); $secs=floor(($diff-(($hours*60*60)+($mins*60)))); if(strlen($hours)<2){ $hours="0".$hours; } if(strlen($mins)<2){ $mins="0".$mins; } if(strlen($secs)<2){ $secs="0".$secs; } return $hours.':'.$mins.':'.$secs; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPHH5
function name:  (null)
number of ops:  18
compiled vars:  !0 = $d, !1 = $h, !2 = $m
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, 4371960
   15     1        INIT_FCALL_BY_NAME                                       'int'
          2        DIV                                              ~4      !0, 3600
          3        SEND_VAL_EX                                              ~4
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   16     6        INIT_FCALL_BY_NAME                                       'int'
          7        MOD                                              ~7      !0, 3600
          8        DIV                                              ~8      ~7, 60
          9        SEND_VAL_EX                                              ~8
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   17    12        ROPE_INIT                                     4  ~12     'son+'
         13        ROPE_ADD                                      1  ~12     ~12, !1
         14        ROPE_ADD                                      2  ~12     ~12, '%3A'
         15        ROPE_END                                      3  ~11     ~12, !2
         16        ECHO                                                     ~11
   44    17      > RETURN                                                   1

Function converttoseconds:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UPHH5
function name:  convertToSeconds
number of ops:  15
compiled vars:  !0 = $time, !1 = $a, !2 = $hora, !3 = $min
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%3A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   21     6        FETCH_DIM_R                                      ~6      !1, 0
          7        ASSIGN                                                   !2, ~6
   22     8        FETCH_DIM_R                                      ~8      !1, 1
          9        ASSIGN                                                   !3, ~8
   23    10        MUL                                              ~10     !2, 3600
         11        MUL                                              ~11     !3, 60
         12        ADD                                              ~12     ~10, ~11
         13      > RETURN                                                   ~12
   24    14*     > RETURN                                                   null

End of function converttoseconds

Function gettimediff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 89
Branch analysis from position: 87
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 94
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 97, Position 2 = 99
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 99
Branch analysis from position: 94
Branch analysis from position: 89
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 87, Position 2 = 89
Branch analysis from position: 87
Branch analysis from position: 89
filename:       /in/UPHH5
function name:  getTimeDiff
number of ops:  105
compiled vars:  !0 = $dtime, !1 = $atime, !2 = $nextDay, !3 = $dep, !4 = $arr, !5 = $diff, !6 = $hours, !7 = $mins, !8 = $secs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        IS_SMALLER                                               !1, !0
          3      > JMPZ                                                     ~9, ->6
          4    >   QM_ASSIGN                                        ~10     1
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~10     0
          7    >   ASSIGN                                                   !2, ~10
   28     8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%3A'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !3, $12
   29    13        INIT_FCALL                                               'explode'
         14        SEND_VAL                                                 '%3A'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !4, $14
   30    18        INIT_FCALL                                               'abs'
         19        INIT_FCALL                                               'mktime'
         20        FETCH_DIM_R                                      ~16     !3, 0
         21        SEND_VAL                                                 ~16
         22        FETCH_DIM_R                                      ~17     !3, 1
         23        SEND_VAL                                                 ~17
         24        SEND_VAL                                                 0
         25        INIT_FCALL                                               'date'
         26        SEND_VAL                                                 'n'
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        INIT_FCALL                                               'date'
         30        SEND_VAL                                                 'j'
         31        DO_ICALL                                         $19     
         32        SEND_VAR                                                 $19
         33        INIT_FCALL                                               'date'
         34        SEND_VAL                                                 'y'
         35        DO_ICALL                                         $20     
         36        SEND_VAR                                                 $20
         37        DO_ICALL                                         $21     
         38        INIT_FCALL                                               'mktime'
         39        FETCH_DIM_R                                      ~22     !4, 0
         40        SEND_VAL                                                 ~22
         41        FETCH_DIM_R                                      ~23     !4, 1
         42        SEND_VAL                                                 ~23
         43        SEND_VAL                                                 0
         44        INIT_FCALL                                               'date'
         45        SEND_VAL                                                 'n'
         46        DO_ICALL                                         $24     
         47        SEND_VAR                                                 $24
         48        INIT_FCALL                                               'date'
         49        SEND_VAL                                                 'j'
         50        DO_ICALL                                         $25     
         51        ADD                                              ~26     $25, !2
         52        SEND_VAL                                                 ~26
         53        INIT_FCALL                                               'date'
         54        SEND_VAL                                                 'y'
         55        DO_ICALL                                         $27     
         56        SEND_VAR                                                 $27
         57        DO_ICALL                                         $28     
         58        SUB                                              ~29     $21, $28
         59        SEND_VAL                                                 ~29
         60        DO_ICALL                                         $30     
         61        ASSIGN                                                   !5, $30
   31    62        INIT_FCALL                                               'floor'
         63        DIV                                              ~32     !5, 3600
         64        SEND_VAL                                                 ~32
         65        DO_ICALL                                         $33     
         66        ASSIGN                                                   !6, $33
   32    67        INIT_FCALL                                               'floor'
         68        MUL                                              ~35     !6, 60
         69        MUL                                              ~36     ~35, 60
         70        SUB                                              ~37     !5, ~36
         71        DIV                                              ~38     ~37, 60
         72        SEND_VAL                                                 ~38
         73        DO_ICALL                                         $39     
         74        ASSIGN                                                   !7, $39
   33    75        INIT_FCALL                                               'floor'
         76        MUL                                              ~41     !6, 60
         77        MUL                                              ~42     ~41, 60
         78        MUL                                              ~43     !7, 60
         79        ADD                                              ~44     ~42, ~43
         80        SUB                                              ~45     !5, ~44
         81        SEND_VAL                                                 ~45
         82        DO_ICALL                                         $46     
         83        ASSIGN                                                   !8, $46
   34    84        STRLEN                                           ~48     !6
         85        IS_SMALLER                                               ~48, 2
         86      > JMPZ                                                     ~49, ->89
   35    87    >   CONCAT                                           ~50     '0', !6
         88        ASSIGN                                                   !6, ~50
   37    89    >   STRLEN                                           ~52     !7
         90        IS_SMALLER                                               ~52, 2
         91      > JMPZ                                                     ~53, ->94
   38    92    >   CONCAT                                           ~54     '0', !7
         93        ASSIGN                                                   !7, ~54
   40    94    >   STRLEN                                           ~56     !8
         95        IS_SMALLER                                               ~56, 2
         96      > JMPZ                                                     ~57, ->99
   41    97    >   CONCAT                                           ~58     '0', !8
         98        ASSIGN                                                   !8, ~58
   43    99    >   CONCAT                                           ~60     !6, '%3A'
        100        CONCAT                                           ~61     ~60, !7
        101        CONCAT                                           ~62     ~61, '%3A'
        102        CONCAT                                           ~63     ~62, !8
        103      > RETURN                                                   ~63
   44   104*     > RETURN                                                   null

End of function gettimediff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.28 ms | 1408 KiB | 23 Q