3v4l.org

run code in 300+ PHP versions simultaneously
<?php // @see https://stackoverflow.com/questions/77131068/how-to-retain-the-time-zone-info-when-truncating-a-timestamp-with-time-zone date_default_timezone_set('UTC'); $dates = [ '1999-12-31 20:59:59+00', '1999-12-31 20:59:59', '2000-01-01 07:29:59', '1999-12-31 20:00:00+00', '1999-12-31 20:00:00', '2000-01-01 07:00:00', '2000-01-01 07:00:00 +00', '2000-01-01 07:00:00 Australia/Adelaide' ]; foreach ($dates as $dateString) { $date = new \DateTimeImmutable($dateString); echo $dateString."\n-> ".$date->format('r')."\n\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/u7A8q
function name:  (null)
number of ops:  20
compiled vars:  !0 = $dates, !1 = $dateString, !2 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'UTC'
          2        DO_ICALL                                                 
    7     3        ASSIGN                                                   !0, <array>
   18     4      > FE_RESET_R                                       $5      !0, ->18
          5    > > FE_FETCH_R                                               $5, !1, ->18
   19     6    >   NEW                                              $6      'DateTimeImmutable'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !2, $6
   20    10        CONCAT                                           ~9      !1, '%0A-%3E+'
         11        INIT_METHOD_CALL                                         !2, 'format'
         12        SEND_VAL_EX                                              'r'
         13        DO_FCALL                                      0  $10     
         14        CONCAT                                           ~11     ~9, $10
         15        CONCAT                                           ~12     ~11, '%0A%0A'
         16        ECHO                                                     ~12
   18    17      > JMP                                                      ->5
         18    >   FE_FREE                                                  $5
   21    19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.98 ms | 1010 KiB | 14 Q