3v4l.org

run code in 300+ PHP versions simultaneously
<?php // vychozi pripocet je cela ctvrthodina $diff = 15; $minutes = date('i'); $minutes = (strlen($minutes) == 2) ? (int) $minutes[1] : (int) $minutes; // najdi nejblizsi celou ctvrthodinu $quarters = array(15, 30, 45, 60); foreach($quarters as $quarter){ $curDiff = $quarter - $minutes; // pokud je interval mensi nez minuly a zaroven kladny // presne 0 je na dane ctvrthodine a to chceme pripocist plnych 15 min if($curDiff < $diff && $curDiff > 0){ $diff = $curDiff; } } $dt = new DateTime; $dt->add(new DateInterval('PT'.$diff.'M')); echo $dt->format('Y-m-d H:i:00'); echo '<br>'.date('H:i');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
Branch analysis from position: 24
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
Branch analysis from position: 27
filename:       /in/4OfTD
function name:  (null)
number of ops:  49
compiled vars:  !0 = $diff, !1 = $minutes, !2 = $quarters, !3 = $quarter, !4 = $curDiff, !5 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 15
    5     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'i'
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
    6     5        STRLEN                                           ~9      !1
          6        IS_EQUAL                                                 ~9, 2
          7      > JMPZ                                                     ~10, ->12
          8    >   FETCH_DIM_R                                      ~11     !1, 1
          9        CAST                                          4  ~12     ~11
         10        QM_ASSIGN                                        ~13     ~12
         11      > JMP                                                      ->14
         12    >   CAST                                          4  ~14     !1
         13        QM_ASSIGN                                        ~13     ~14
         14    >   ASSIGN                                                   !1, ~13
    9    15        ASSIGN                                                   !2, <array>
   10    16      > FE_RESET_R                                       $17     !2, ->27
         17    > > FE_FETCH_R                                               $17, !3, ->27
   11    18    >   SUB                                              ~18     !3, !1
         19        ASSIGN                                                   !4, ~18
   15    20        IS_SMALLER                                       ~20     !4, !0
         21      > JMPZ_EX                                          ~20     ~20, ->24
         22    >   IS_SMALLER                                       ~21     0, !4
         23        BOOL                                             ~20     ~21
         24    > > JMPZ                                                     ~20, ->26
   16    25    >   ASSIGN                                                   !0, !4
   10    26    > > JMP                                                      ->17
         27    >   FE_FREE                                                  $17
   20    28        NEW                                              $23     'DateTime'
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !5, $23
   21    31        INIT_METHOD_CALL                                         !5, 'add'
         32        NEW                                              $26     'DateInterval'
         33        CONCAT                                           ~27     'PT', !0
         34        CONCAT                                           ~28     ~27, 'M'
         35        SEND_VAL_EX                                              ~28
         36        DO_FCALL                                      0          
         37        SEND_VAR_NO_REF_EX                                       $26
         38        DO_FCALL                                      0          
   23    39        INIT_METHOD_CALL                                         !5, 'format'
         40        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3A00'
         41        DO_FCALL                                      0  $31     
         42        ECHO                                                     $31
   24    43        INIT_FCALL                                               'date'
         44        SEND_VAL                                                 'H%3Ai'
         45        DO_ICALL                                         $32     
         46        CONCAT                                           ~33     '%3Cbr%3E', $32
         47        ECHO                                                     ~33
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.31 ms | 1400 KiB | 15 Q