3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getYearsBetween( \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ): int { $dateInterval = $startDate->diff($endDate, true); return $dateInterval->y; } $start = new \DateTimeImmutable('2000-11-01 09:29:22.907606', new \DateTimeZone('America/Chicago')); $end = new \DateTimeImmutable('2022-06-06 11:00:00.000000', new \DateTimeZone('America/New_York')); $end = $end->setTimezone(new \DateTimeZone('America/Chicago')); $result = getYearsBetween($start, $end); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RK34h
function name:  (null)
number of ops:  32
compiled vars:  !0 = $start, !1 = $end, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   NEW                                                  $3      'DateTimeImmutable'
          1        SEND_VAL_EX                                                  '2000-11-01+09%3A29%3A22.907606'
          2        NEW                                                  $4      'DateTimeZone'
          3        SEND_VAL_EX                                                  'America%2FChicago'
          4        DO_FCALL                                          0          
          5        SEND_VAR_NO_REF_EX                                           $4
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !0, $3
   12     8        NEW                                                  $8      'DateTimeImmutable'
          9        SEND_VAL_EX                                                  '2022-06-06+11%3A00%3A00.000000'
         10        NEW                                                  $9      'DateTimeZone'
         11        SEND_VAL_EX                                                  'America%2FNew_York'
         12        DO_FCALL                                          0          
         13        SEND_VAR_NO_REF_EX                                           $9
         14        DO_FCALL                                          0          
         15        ASSIGN                                                       !1, $8
   13    16        INIT_METHOD_CALL                                             !1, 'setTimezone'
         17        NEW                                                  $13     'DateTimeZone'
         18        SEND_VAL_EX                                                  'America%2FChicago'
         19        DO_FCALL                                          0          
         20        SEND_VAR_NO_REF_EX                                           $13
         21        DO_FCALL                                          0  $15     
         22        ASSIGN                                                       !1, $15
   14    23        INIT_FCALL                                                   'getyearsbetween'
         24        SEND_VAR                                                     !0
         25        SEND_VAR                                                     !1
         26        DO_FCALL                                          0  $17     
         27        ASSIGN                                                       !2, $17
   15    28        INIT_FCALL                                                   'var_export'
         29        SEND_VAR                                                     !2
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Function getyearsbetween:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RK34h
function name:  getYearsBetween
number of ops:  12
compiled vars:  !0 = $startDate, !1 = $endDate, !2 = $dateInterval
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   RECV                                                 !0      
    5     1        RECV                                                 !1      
    7     2        INIT_METHOD_CALL                                             !0, 'diff'
          3        SEND_VAR_EX                                                  !1
          4        SEND_VAL_EX                                                  <true>
          5        DO_FCALL                                          0  $3      
          6        ASSIGN                                                       !2, $3
    8     7        FETCH_OBJ_R                                          ~5      !2, 'y'
          8        VERIFY_RETURN_TYPE                                           ~5
          9      > RETURN                                                       ~5
    9    10*       VERIFY_RETURN_TYPE                                           
         11*     > RETURN                                                       null

End of function getyearsbetween

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.04 ms | 1860 KiB | 15 Q