3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date1 = "2016-01-12"; $date2 = "2016-01-13"; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); $numberDays = $diff/86400; // 86400 seconds in one day printf("%d years, %d months, %d days\n", $years, $months, $days); printf("%d numberDays", $numberDays);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D7RWU
function name:  (null)
number of ops:  56
compiled vars:  !0 = $date1, !1 = $date2, !2 = $diff, !3 = $years, !4 = $months, !5 = $days, !6 = $numberDays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2016-01-12'
    4     1        ASSIGN                                                   !1, '2016-01-13'
    6     2        INIT_FCALL                                               'abs'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $9      
          6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $10     
          9        SUB                                              ~11     $9, $10
         10        SEND_VAL                                                 ~11
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !2, $12
    8    13        INIT_FCALL                                               'floor'
         14        DIV                                              ~14     !2, 31536000
         15        SEND_VAL                                                 ~14
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !3, $15
    9    18        INIT_FCALL                                               'floor'
         19        MUL                                              ~17     !3, 365
         20        MUL                                              ~18     ~17, 60
         21        MUL                                              ~19     ~18, 60
         22        MUL                                              ~20     ~19, 24
         23        SUB                                              ~21     !2, ~20
         24        DIV                                              ~22     ~21, 2592000
         25        SEND_VAL                                                 ~22
         26        DO_ICALL                                         $23     
         27        ASSIGN                                                   !4, $23
   10    28        INIT_FCALL                                               'floor'
         29        MUL                                              ~25     !3, 365
         30        MUL                                              ~26     ~25, 60
         31        MUL                                              ~27     ~26, 60
         32        MUL                                              ~28     ~27, 24
         33        SUB                                              ~29     !2, ~28
         34        MUL                                              ~30     !4, 30
         35        MUL                                              ~31     ~30, 60
         36        MUL                                              ~32     ~31, 60
         37        MUL                                              ~33     ~32, 24
         38        SUB                                              ~34     ~29, ~33
         39        DIV                                              ~35     ~34, 86400
         40        SEND_VAL                                                 ~35
         41        DO_ICALL                                         $36     
         42        ASSIGN                                                   !5, $36
   12    43        DIV                                              ~38     !2, 86400
         44        ASSIGN                                                   !6, ~38
   15    45        INIT_FCALL                                               'printf'
         46        SEND_VAL                                                 '%25d+years%2C+%25d+months%2C+%25d+days%0A'
         47        SEND_VAR                                                 !3
         48        SEND_VAR                                                 !4
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                                 
   16    51        INIT_FCALL                                               'printf'
         52        SEND_VAL                                                 '%25d+numberDays'
         53        SEND_VAR                                                 !6
         54        DO_ICALL                                                 
         55      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.11 ms | 1400 KiB | 21 Q