3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date1 = "2016-01-12 10:10:10"; $date2 = "2016-01-13 10:11:10"; //$diff = abs(strtotime($date2) - strtotime($date1)); $diff = abs(date("Y-m-d",strtotime($date2)) - date("Y-m-d",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/Ii2DF
function name:  (null)
number of ops:  64
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+10%3A10%3A10'
    4     1        ASSIGN                                                   !1, '2016-01-13+10%3A11%3A10'
    7     2        INIT_FCALL                                               'abs'
          3        INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'Y-m-d'
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $9      
          8        SEND_VAR                                                 $9
          9        DO_ICALL                                         $10     
         10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'Y-m-d'
         12        INIT_FCALL                                               'strtotime'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                         $12     
         17        SUB                                              ~13     $10, $12
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $14     
         20        ASSIGN                                                   !2, $14
   10    21        INIT_FCALL                                               'floor'
         22        DIV                                              ~16     !2, 31536000
         23        SEND_VAL                                                 ~16
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !3, $17
   11    26        INIT_FCALL                                               'floor'
         27        MUL                                              ~19     !3, 365
         28        MUL                                              ~20     ~19, 60
         29        MUL                                              ~21     ~20, 60
         30        MUL                                              ~22     ~21, 24
         31        SUB                                              ~23     !2, ~22
         32        DIV                                              ~24     ~23, 2592000
         33        SEND_VAL                                                 ~24
         34        DO_ICALL                                         $25     
         35        ASSIGN                                                   !4, $25
   12    36        INIT_FCALL                                               'floor'
         37        MUL                                              ~27     !3, 365
         38        MUL                                              ~28     ~27, 60
         39        MUL                                              ~29     ~28, 60
         40        MUL                                              ~30     ~29, 24
         41        SUB                                              ~31     !2, ~30
         42        MUL                                              ~32     !4, 30
         43        MUL                                              ~33     ~32, 60
         44        MUL                                              ~34     ~33, 60
         45        MUL                                              ~35     ~34, 24
         46        SUB                                              ~36     ~31, ~35
         47        DIV                                              ~37     ~36, 86400
         48        SEND_VAL                                                 ~37
         49        DO_ICALL                                         $38     
         50        ASSIGN                                                   !5, $38
   14    51        DIV                                              ~40     !2, 86400
         52        ASSIGN                                                   !6, ~40
   17    53        INIT_FCALL                                               'printf'
         54        SEND_VAL                                                 '%25d+years%2C+%25d+months%2C+%25d+days%0A'
         55        SEND_VAR                                                 !3
         56        SEND_VAR                                                 !4
         57        SEND_VAR                                                 !5
         58        DO_ICALL                                                 
   18    59        INIT_FCALL                                               'printf'
         60        SEND_VAL                                                 '%25d+numberDays'
         61        SEND_VAR                                                 !6
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.11 ms | 1400 KiB | 23 Q