3v4l.org

run code in 300+ PHP versions simultaneously
<?php if( method_exists('DateTime', 'diff') ){ $zone = new DateTimeZone('Europe/Madrid'); $start = new DateTime('2013-03-31 1:59:00 ', $zone); $end = new DateTime('2013-03-31 3:00:00', $zone); $difference = $start->diff($end); $cet = $difference->format('%H:%I:%S'); echo "CET: $cet\n"; $start->setTimeZone(new DateTimeZone('UTC')); $end->setTimeZone(new DateTimeZone('UTC')); $difference = $start->diff($end); $utm = $difference->format('%H:%I:%S'); echo "UTM: $utm\n"; echo ($cet===$utm ? 'Correct' : 'Error') . "\n"; }else{ echo 'DateTime::diff() no available yet'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 63
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MVWMG
function name:  (null)
number of ops:  65
compiled vars:  !0 = $zone, !1 = $start, !2 = $end, !3 = $difference, !4 = $cet, !5 = $utm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'method_exists'
          1        SEND_VAL                                                 'DateTime'
          2        SEND_VAL                                                 'diff'
          3        DO_ICALL                                         $6      
          4      > JMPZ                                                     $6, ->63
    4     5    >   NEW                                              $7      'DateTimeZone'
          6        SEND_VAL_EX                                              'Europe%2FMadrid'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $7
    5     9        NEW                                              $10     'DateTime'
         10        SEND_VAL_EX                                              '2013-03-31+1%3A59%3A00+'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $10
    6    14        NEW                                              $13     'DateTime'
         15        SEND_VAL_EX                                              '2013-03-31+3%3A00%3A00'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !2, $13
    8    19        INIT_METHOD_CALL                                         !1, 'diff'
         20        SEND_VAR_EX                                              !2
         21        DO_FCALL                                      0  $16     
         22        ASSIGN                                                   !3, $16
    9    23        INIT_METHOD_CALL                                         !3, 'format'
         24        SEND_VAL_EX                                              '%25H%3A%25I%3A%25S'
         25        DO_FCALL                                      0  $18     
         26        ASSIGN                                                   !4, $18
   10    27        ROPE_INIT                                     3  ~21     'CET%3A+'
         28        ROPE_ADD                                      1  ~21     ~21, !4
         29        ROPE_END                                      2  ~20     ~21, '%0A'
         30        ECHO                                                     ~20
   12    31        INIT_METHOD_CALL                                         !1, 'setTimeZone'
         32        NEW                                              $23     'DateTimeZone'
         33        SEND_VAL_EX                                              'UTC'
         34        DO_FCALL                                      0          
         35        SEND_VAR_NO_REF_EX                                       $23
         36        DO_FCALL                                      0          
   13    37        INIT_METHOD_CALL                                         !2, 'setTimeZone'
         38        NEW                                              $26     'DateTimeZone'
         39        SEND_VAL_EX                                              'UTC'
         40        DO_FCALL                                      0          
         41        SEND_VAR_NO_REF_EX                                       $26
         42        DO_FCALL                                      0          
   14    43        INIT_METHOD_CALL                                         !1, 'diff'
         44        SEND_VAR_EX                                              !2
         45        DO_FCALL                                      0  $29     
         46        ASSIGN                                                   !3, $29
   15    47        INIT_METHOD_CALL                                         !3, 'format'
         48        SEND_VAL_EX                                              '%25H%3A%25I%3A%25S'
         49        DO_FCALL                                      0  $31     
         50        ASSIGN                                                   !5, $31
   16    51        ROPE_INIT                                     3  ~34     'UTM%3A+'
         52        ROPE_ADD                                      1  ~34     ~34, !5
         53        ROPE_END                                      2  ~33     ~34, '%0A'
         54        ECHO                                                     ~33
   18    55        IS_IDENTICAL                                             !4, !5
         56      > JMPZ                                                     ~36, ->59
         57    >   QM_ASSIGN                                        ~37     'Correct'
         58      > JMP                                                      ->60
         59    >   QM_ASSIGN                                        ~37     'Error'
         60    >   CONCAT                                           ~38     ~37, '%0A'
         61        ECHO                                                     ~38
         62      > JMP                                                      ->64
   21    63    >   ECHO                                                     'DateTime%3A%3Adiff%28%29+no+available+yet'
   22    64    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.31 ms | 1400 KiB | 15 Q