3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Madrid'); $start = new DateTime('2017-03-26 01:59:00'); $increments = array( '+60 minutes' => '2017-03-26 03:59:00', '+61 minutes' => '2017-03-26 04:00:00', ); echo 'Start: ' . $start->format('r') . PHP_EOL; $local = $start->getTimezone(); $utc = new DateTimeZone('UTC'); foreach ($increments as $increment => $expected_string) { echo '>>> ' . $increment . PHP_EOL; $expected_end = new DateTime($expected_string); $actual_end = clone $start; $actual_end->setTimezone($utc); $actual_end->modify($increment); $actual_end->setTimezone($local); echo 'Expected end: ' . $expected_end->format('r') . PHP_EOL; echo 'Actual end: ' . $actual_end->format('r') . PHP_EOL; echo ($expected_end->format('c')===$actual_end->format('c') ? 'OK' : 'ERROR') . PHP_EOL; echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 69
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 69
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 64
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
filename:       /in/233hp
function name:  (null)
number of ops:  71
compiled vars:  !0 = $start, !1 = $increments, !2 = $local, !3 = $utc, !4 = $expected_string, !5 = $increment, !6 = $expected_end, !7 = $actual_end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'Europe%2FMadrid'
          2        DO_ICALL                                                 
    5     3        NEW                                              $9      'DateTime'
          4        SEND_VAL_EX                                              '2017-03-26+01%3A59%3A00'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $9
    6     7        ASSIGN                                                   !1, <array>
   11     8        INIT_METHOD_CALL                                         !0, 'format'
          9        SEND_VAL_EX                                              'r'
         10        DO_FCALL                                      0  $13     
         11        CONCAT                                           ~14     'Start%3A++++++++', $13
         12        CONCAT                                           ~15     ~14, '%0A'
         13        ECHO                                                     ~15
   12    14        INIT_METHOD_CALL                                         !0, 'getTimezone'
         15        DO_FCALL                                      0  $16     
         16        ASSIGN                                                   !2, $16
   13    17        NEW                                              $18     'DateTimeZone'
         18        SEND_VAL_EX                                              'UTC'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $18
   14    21      > FE_RESET_R                                       $21     !1, ->69
         22    > > FE_FETCH_R                                       ~22     $21, !4, ->69
         23    >   ASSIGN                                                   !5, ~22
   15    24        CONCAT                                           ~24     '%3E%3E%3E+', !5
         25        CONCAT                                           ~25     ~24, '%0A'
         26        ECHO                                                     ~25
   17    27        NEW                                              $26     'DateTime'
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !6, $26
   18    31        CLONE                                            ~29     !0
         32        ASSIGN                                                   !7, ~29
   19    33        INIT_METHOD_CALL                                         !7, 'setTimezone'
         34        SEND_VAR_EX                                              !3
         35        DO_FCALL                                      0          
   20    36        INIT_METHOD_CALL                                         !7, 'modify'
         37        SEND_VAR_EX                                              !5
         38        DO_FCALL                                      0          
   21    39        INIT_METHOD_CALL                                         !7, 'setTimezone'
         40        SEND_VAR_EX                                              !2
         41        DO_FCALL                                      0          
   23    42        INIT_METHOD_CALL                                         !6, 'format'
         43        SEND_VAL_EX                                              'r'
         44        DO_FCALL                                      0  $34     
         45        CONCAT                                           ~35     'Expected+end%3A+', $34
         46        CONCAT                                           ~36     ~35, '%0A'
         47        ECHO                                                     ~36
   24    48        INIT_METHOD_CALL                                         !7, 'format'
         49        SEND_VAL_EX                                              'r'
         50        DO_FCALL                                      0  $37     
         51        CONCAT                                           ~38     'Actual+end%3A+++', $37
         52        CONCAT                                           ~39     ~38, '%0A'
         53        ECHO                                                     ~39
   25    54        INIT_METHOD_CALL                                         !6, 'format'
         55        SEND_VAL_EX                                              'c'
         56        DO_FCALL                                      0  $40     
         57        INIT_METHOD_CALL                                         !7, 'format'
         58        SEND_VAL_EX                                              'c'
         59        DO_FCALL                                      0  $41     
         60        IS_IDENTICAL                                             $40, $41
         61      > JMPZ                                                     ~42, ->64
         62    >   QM_ASSIGN                                        ~43     'OK'
         63      > JMP                                                      ->65
         64    >   QM_ASSIGN                                        ~43     'ERROR'
         65    >   CONCAT                                           ~44     ~43, '%0A'
         66        ECHO                                                     ~44
   26    67        ECHO                                                     '%0A'
   14    68      > JMP                                                      ->22
         69    >   FE_FREE                                                  $21
   27    70      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.05 ms | 1400 KiB | 15 Q