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(512.168)->format("%H:%I:%S");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/88cqu
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                                                 512.168
          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/88cqu
function name:  decTimeToInterval
number of ops:  31
compiled vars:  !0 = $decimalTime, !1 = $hours, !2 = $minutes, !3 = $seconds, !4 = $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                                         $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
   14    13        INIT_FCALL                                               'floor'
         14        MUL                                              ~13     !0, 3600
         15        SEND_VAL                                                 ~13
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !3, $14
   16    18        NEW                                              $16     'DateInterval'
         19        ROPE_INIT                                     7  ~18     'PT'
         20        ROPE_ADD                                      1  ~18     ~18, !1
         21        ROPE_ADD                                      2  ~18     ~18, 'H'
         22        ROPE_ADD                                      3  ~18     ~18, !2
         23        ROPE_ADD                                      4  ~18     ~18, 'M'
         24        ROPE_ADD                                      5  ~18     ~18, !3
         25        ROPE_END                                      6  ~17     ~18, 'S'
         26        SEND_VAL_EX                                              ~17
         27        DO_FCALL                                      0          
         28        ASSIGN                                                   !4, $16
   17    29      > RETURN                                                   !4
   18    30*     > RETURN                                                   null

End of function dectimetointerval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.12 ms | 1403 KiB | 16 Q