3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Test data $lead = array('date_created' => '2014-05-05 12:30:30'); date_default_timezone_set('Europe/London'); // The source timezone $sourceTimezone = new DateTimeZone('UTC'); // The target timezone $targetTimezone = new DateTimeZone(date_default_timezone_get()); // Craft the DateTime from a string and pass the target timezone in $date = DateTime::createFromFormat('Y-m-d H:i:s', $lead['date_created'], $sourceTimezone); // Add two hours to the DateTime object, fixing the timezone $date->add(new DateInterval('PT2H')); // Set the timezone to "our" timezone $date->setTimezone($targetTimezone); var_dump($date); var_dump($date->format('Y-m-d H:i'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e02aa
function name:  (null)
number of ops:  40
compiled vars:  !0 = $lead, !1 = $sourceTimezone, !2 = $targetTimezone, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    7     1        INIT_FCALL                                               'date_default_timezone_set'
          2        SEND_VAL                                                 'Europe%2FLondon'
          3        DO_ICALL                                                 
   11     4        NEW                                              $6      'DateTimeZone'
          5        SEND_VAL_EX                                              'UTC'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   14     8        NEW                                              $9      'DateTimeZone'
          9        INIT_FCALL                                               'date_default_timezone_get'
         10        DO_ICALL                                         $10     
         11        SEND_VAR_NO_REF_EX                                       $10
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !2, $9
   17    14        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
         15        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         16        FETCH_DIM_R                                      ~13     !0, 'date_created'
         17        SEND_VAL                                                 ~13
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $14     
         20        ASSIGN                                                   !3, $14
   20    21        INIT_METHOD_CALL                                         !3, 'add'
         22        NEW                                              $16     'DateInterval'
         23        SEND_VAL_EX                                              'PT2H'
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $16
         26        DO_FCALL                                      0          
   23    27        INIT_METHOD_CALL                                         !3, 'setTimezone'
         28        SEND_VAR_EX                                              !2
         29        DO_FCALL                                      0          
   26    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
   28    33        INIT_FCALL                                               'var_dump'
         34        INIT_METHOD_CALL                                         !3, 'format'
         35        SEND_VAL_EX                                              'Y-m-d+H%3Ai'
         36        DO_FCALL                                      0  $21     
         37        SEND_VAR                                                 $21
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.78 ms | 1401 KiB | 19 Q