3v4l.org

run code in 300+ PHP versions simultaneously
<?php $datetime1 = new \DateTimeImmutable('9999-01-02 15:00:00.000000', new \DateTimeZone('UTC')); try { $datetime2 = $datetime1->add(new \DateInterval('P1Y')); echo $datetime2->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \PHP_EOL; } $datetime3 = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s.u', $datetime2->format('Y-m-d H:i:s.u'), new \DateTimeZone('UTC')); if ($datetime3 !== false) { echo $datetime3->format('Y-m-d H:i:s.u') . \PHP_EOL; } else { echo 'false' . \PHP_EOL; } try { $datetime4 = new \DateTimeImmutable($datetime2->format('Y-m-d H:i:s.u'), new \DateTimeZone('UTC')); echo $datetime4->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \PHP_EOL; } // Workaround with fake year try { $datetime5 = new \DateTimeImmutable($datetime2->format('1234-m-d H:i:s.u'), new \DateTimeZone('UTC')); $datetime5 = $datetime5->setDate((int)$datetime2->format("Y"), (int)$datetime2->format("n"), (int)$datetime2->format("j")); echo $datetime5->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Found catch point at position: 21
Branch analysis from position: 21
2 jumps found. (Code = 107) Position 1 = 22, Position 2 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
Branch analysis from position: 43
Found catch point at position: 61
Branch analysis from position: 61
2 jumps found. (Code = 107) Position 1 = 62, Position 2 = -2
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Found catch point at position: 98
Branch analysis from position: 98
2 jumps found. (Code = 107) Position 1 = 99, Position 2 = -2
Branch analysis from position: 99
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1bl8m
function name:  (null)
number of ops:  101
compiled vars:  !0 = $datetime1, !1 = $datetime2, !2 = $e, !3 = $datetime3, !4 = $datetime4, !5 = $datetime5
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $6      'DateTimeImmutable'
          1        SEND_VAL_EX                                              '9999-01-02+15%3A00%3A00.000000'
          2        NEW                                              $7      'DateTimeZone'
          3        SEND_VAL_EX                                              'UTC'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $7
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $6
    6     8        INIT_METHOD_CALL                                         !0, 'add'
          9        NEW                                              $11     'DateInterval'
         10        SEND_VAL_EX                                              'P1Y'
         11        DO_FCALL                                      0          
         12        SEND_VAR_NO_REF_EX                                       $11
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !1, $13
    7    15        INIT_METHOD_CALL                                         !1, 'format'
         16        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         17        DO_FCALL                                      0  $15     
         18        CONCAT                                           ~16     $15, '%0A'
         19        ECHO                                                     ~16
         20      > JMP                                                      ->23
    8    21  E > > CATCH                                       last         'Throwable'
    9    22    >   ECHO                                                     'exception%0A'
   12    23    >   INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
         24        SEND_VAL                                                 'Y-m-d+H%3Ai%3As.u'
         25        INIT_METHOD_CALL                                         !1, 'format'
         26        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         27        DO_FCALL                                      0  $17     
         28        SEND_VAR                                                 $17
         29        NEW                                              $18     'DateTimeZone'
         30        SEND_VAL_EX                                              'UTC'
         31        DO_FCALL                                      0          
         32        SEND_VAR                                                 $18
         33        DO_FCALL                                      0  $20     
         34        ASSIGN                                                   !3, $20
   13    35        TYPE_CHECK                                  1018          !3
         36      > JMPZ                                                     ~22, ->43
   14    37    >   INIT_METHOD_CALL                                         !3, 'format'
         38        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         39        DO_FCALL                                      0  $23     
         40        CONCAT                                           ~24     $23, '%0A'
         41        ECHO                                                     ~24
         42      > JMP                                                      ->44
   16    43    >   ECHO                                                     'false%0A'
   20    44    >   NEW                                              $25     'DateTimeImmutable'
         45        INIT_METHOD_CALL                                         !1, 'format'
         46        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         47        DO_FCALL                                      0  $26     
         48        SEND_VAR_NO_REF_EX                                       $26
         49        NEW                                              $27     'DateTimeZone'
         50        SEND_VAL_EX                                              'UTC'
         51        DO_FCALL                                      0          
         52        SEND_VAR_NO_REF_EX                                       $27
         53        DO_FCALL                                      0          
         54        ASSIGN                                                   !4, $25
   21    55        INIT_METHOD_CALL                                         !4, 'format'
         56        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         57        DO_FCALL                                      0  $31     
         58        CONCAT                                           ~32     $31, '%0A'
         59        ECHO                                                     ~32
         60      > JMP                                                      ->63
   22    61  E > > CATCH                                       last         'Throwable'
   23    62    >   ECHO                                                     'exception%0A'
   28    63    >   NEW                                              $33     'DateTimeImmutable'
         64        INIT_METHOD_CALL                                         !1, 'format'
         65        SEND_VAL_EX                                              '1234-m-d+H%3Ai%3As.u'
         66        DO_FCALL                                      0  $34     
         67        SEND_VAR_NO_REF_EX                                       $34
         68        NEW                                              $35     'DateTimeZone'
         69        SEND_VAL_EX                                              'UTC'
         70        DO_FCALL                                      0          
         71        SEND_VAR_NO_REF_EX                                       $35
         72        DO_FCALL                                      0          
         73        ASSIGN                                                   !5, $33
   29    74        INIT_METHOD_CALL                                         !5, 'setDate'
         75        INIT_METHOD_CALL                                         !1, 'format'
         76        SEND_VAL_EX                                              'Y'
         77        DO_FCALL                                      0  $39     
         78        CAST                                          4  ~40     $39
         79        SEND_VAL_EX                                              ~40
         80        INIT_METHOD_CALL                                         !1, 'format'
         81        SEND_VAL_EX                                              'n'
         82        DO_FCALL                                      0  $41     
         83        CAST                                          4  ~42     $41
         84        SEND_VAL_EX                                              ~42
         85        INIT_METHOD_CALL                                         !1, 'format'
         86        SEND_VAL_EX                                              'j'
         87        DO_FCALL                                      0  $43     
         88        CAST                                          4  ~44     $43
         89        SEND_VAL_EX                                              ~44
         90        DO_FCALL                                      0  $45     
         91        ASSIGN                                                   !5, $45
   30    92        INIT_METHOD_CALL                                         !5, 'format'
         93        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As.u'
         94        DO_FCALL                                      0  $47     
         95        CONCAT                                           ~48     $47, '%0A'
         96        ECHO                                                     ~48
         97      > JMP                                                      ->100
   31    98  E > > CATCH                                       last         'Throwable'
   32    99    >   ECHO                                                     'exception%0A'
   33   100    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
12.09 ms | 420 KiB | 7 Q