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{$seconds}S"); 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/id082
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/id082
function name:  decTimeToInterval
number of ops:  26
compiled vars:  !0 = $decimalTime, !1 = $hours, !2 = $minutes, !3 = $interval, !4 = $seconds
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                                         $5      
          4        ASSIGN                                                   !1, $5
   11     5        ASSIGN_OP                                     2          !0, !1
   12     6        INIT_FCALL                                               'floor'
          7        MUL                                              ~8      !0, 60
          8        SEND_VAL                                                 ~8
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !2, $9
   13    11        DIV                                              ~11     !2, 60
         12        ASSIGN_OP                                     2          !0, ~11
   16    13        NEW                                              $13     'DateInterval'
         14        ROPE_INIT                                     7  ~15     'PT'
         15        ROPE_ADD                                      1  ~15     ~15, !1
         16        ROPE_ADD                                      2  ~15     ~15, 'H'
         17        ROPE_ADD                                      3  ~15     ~15, !2
         18        ROPE_ADD                                      4  ~15     ~15, 'M'
         19        ROPE_ADD                                      5  ~15     ~15, !4
         20        ROPE_END                                      6  ~14     ~15, 'S'
         21        SEND_VAL_EX                                              ~14
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !3, $13
   17    24      > RETURN                                                   !3
   18    25*     > RETURN                                                   null

End of function dectimetointerval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.11 ms | 1399 KiB | 16 Q