3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDateTime = new DateTime('2016-10-17'); $currentDate = new DateTime('2017-2-5'); //$startDateTime->modify('+1 day'); $currentWeekNumber = $currentDate->format('W') + (($currentDate->format('o') - $startDateTime->format('o')) * 52); //Subtract the start week from the current week (and add 1, since we start at Week 1) to find the current study week echo $currentWeekNumber - $startDateTime->format('W') + 1;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1J6sp
function name:  (null)
number of ops:  28
compiled vars:  !0 = $startDateTime, !1 = $currentDate, !2 = $currentWeekNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              '2016-10-17'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    4     4        NEW                                              $6      'DateTime'
          5        SEND_VAL_EX                                              '2017-2-5'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
    7     8        INIT_METHOD_CALL                                         !1, 'format'
          9        SEND_VAL_EX                                              'W'
         10        DO_FCALL                                      0  $9      
         11        INIT_METHOD_CALL                                         !1, 'format'
         12        SEND_VAL_EX                                              'o'
         13        DO_FCALL                                      0  $10     
         14        INIT_METHOD_CALL                                         !0, 'format'
         15        SEND_VAL_EX                                              'o'
         16        DO_FCALL                                      0  $11     
         17        SUB                                              ~12     $10, $11
         18        MUL                                              ~13     ~12, 52
         19        ADD                                              ~14     $9, ~13
         20        ASSIGN                                                   !2, ~14
   10    21        INIT_METHOD_CALL                                         !0, 'format'
         22        SEND_VAL_EX                                              'W'
         23        DO_FCALL                                      0  $16     
         24        SUB                                              ~17     !2, $16
         25        ADD                                              ~18     ~17, 1
         26        ECHO                                                     ~18
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.92 ms | 1394 KiB | 13 Q