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) { $hours = floor($decimalTime); $decimalTime -= $hours; $minutes = floor($decimalTime * 60); $decimalTime -= ($minutes/60); //$seconds = floor($decimalTime * 3600); $interval = new \DateInterval("PT{$hours}H{$minutes}M"); return $interval; } echo decTimeToInterval(1.6890000)->format("%H:%I");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7OsvV
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'dectimetointerval'
          1        SEND_VAL                                                 1.689
          2        DO_FCALL                                      0  $0      
          3        INIT_METHOD_CALL                                         $0, 'format'
          4        SEND_VAL_EX                                              '%25H%3A%25I'
          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/7OsvV
function name:  decTimeToInterval
number of ops:  24
compiled vars:  !0 = $decimalTime, !1 = $hours, !2 = $minutes, !3 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'floor'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   11     5        ASSIGN_OP                                     2          !0, !1
   12     6        INIT_FCALL                                               'floor'
          7        MUL                                              ~7      !0, 60
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
   13    11        DIV                                              ~10     !2, 60
         12        ASSIGN_OP                                     2          !0, ~10
   16    13        NEW                                              $12     'DateInterval'
         14        ROPE_INIT                                     5  ~14     'PT'
         15        ROPE_ADD                                      1  ~14     ~14, !1
         16        ROPE_ADD                                      2  ~14     ~14, 'H'
         17        ROPE_ADD                                      3  ~14     ~14, !2
         18        ROPE_END                                      4  ~13     ~14, 'M'
         19        SEND_VAL_EX                                              ~13
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !3, $12
   17    22      > RETURN                                                   !3
   18    23*     > RETURN                                                   null

End of function dectimetointerval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.38 ms | 1399 KiB | 16 Q