3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Converts a 'decimal time' in the format 1.5hours to DateInterval object * * @param Int $decimalTime * @return DateInterval */ function decTimeToInterval($decimalTime) { $seconds = round($decimalTime * 3600); $interval = \DateInterval::createFromDateString("$seconds seconds"); $start = new \DateTime(); $end = clone($start); $end->add($interval); $interval = $start->diff($end); return $interval; } echo decTimeToInterval(12.33)->format("%H:%I:%S");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0c3f6
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'dectimetointerval'
          1        SEND_VAL                                                 12.33
          2        DO_FCALL                                      0  $0      
          3        INIT_METHOD_CALL                                         $0, 'format'
          4        SEND_VAL_EX                                              '%25H%3A%25I%3A%25S'
          5        DO_FCALL                                      0  $1      
          6        ECHO                                                     $1
          7      > RETURN                                                   1

Function dectimetointerval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0c3f6
function name:  decTimeToInterval
number of ops:  26
compiled vars:  !0 = $decimalTime, !1 = $seconds, !2 = $interval, !3 = $start, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'round'
          2        MUL                                              ~5      !0, 3600
          3        SEND_VAL                                                 ~5
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   11     6        INIT_STATIC_METHOD_CALL                                  'DateInterval', 'createFromDateString'
          7        NOP                                                      
          8        FAST_CONCAT                                      ~8      !1, '+seconds'
          9        SEND_VAL                                                 ~8
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   12    12        NEW                                              $11     'DateTime'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $11
   13    15        CLONE                                            ~14     !3
         16        ASSIGN                                                   !4, ~14
   14    17        INIT_METHOD_CALL                                         !4, 'add'
         18        SEND_VAR_EX                                              !2
         19        DO_FCALL                                      0          
   15    20        INIT_METHOD_CALL                                         !3, 'diff'
         21        SEND_VAR_EX                                              !4
         22        DO_FCALL                                      0  $17     
         23        ASSIGN                                                   !2, $17
   16    24      > RETURN                                                   !2
   17    25*     > RETURN                                                   null

End of function dectimetointerval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.42 ms | 1403 KiB | 16 Q