3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new DateTime('2014-01-07', new DateTimeZone('UTC')); $end = clone $start; $start->sub(new DateInterval('P1M')); // substract one month echo $start->format('Y-m-d').' - '.$end->format('Y-m-d'); // 2013-12-07 - 2014-01-07 - seems correct, let's get number of days... print_r($end->diff($start)); // DateInterval Object ( [y] => 0 [m] => 2 [d] => 0 [h] => 0 [i] => 0 [s] => 0 [invert] => 1 [days] => 61 )
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/76XK2
function name:  (null)
number of ops:  32
compiled vars:  !0 = $start, !1 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              '2014-01-07'
          2        NEW                                              $3      'DateTimeZone'
          3        SEND_VAL_EX                                              'UTC'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $3
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $2
    4     8        CLONE                                            ~7      !0
          9        ASSIGN                                                   !1, ~7
    5    10        INIT_METHOD_CALL                                         !0, 'sub'
         11        NEW                                              $9      'DateInterval'
         12        SEND_VAL_EX                                              'P1M'
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $9
         15        DO_FCALL                                      0          
    7    16        INIT_METHOD_CALL                                         !0, 'format'
         17        SEND_VAL_EX                                              'Y-m-d'
         18        DO_FCALL                                      0  $12     
         19        CONCAT                                           ~13     $12, '+-+'
         20        INIT_METHOD_CALL                                         !1, 'format'
         21        SEND_VAL_EX                                              'Y-m-d'
         22        DO_FCALL                                      0  $14     
         23        CONCAT                                           ~15     ~13, $14
         24        ECHO                                                     ~15
   10    25        INIT_FCALL                                               'print_r'
         26        INIT_METHOD_CALL                                         !1, 'diff'
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0  $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                                 
   11    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.2 ms | 1395 KiB | 15 Q