@ 2016-12-02T11:31:57Z <?php
//Enter your code here, enjoy!
$fechaMIN = "2011-01-01";
$fechaMAX = "2012-05-31";
$ts1 = strtotime( $fechaMIN );
$ts2 = strtotime( $fechaMAX );
$year1 = date( 'Y', $ts1 );
$year2 = date( 'Y', $ts2 );
$month1 = date( 'm', $ts1 );
$month2 = date( 'm', $ts2 );
$day1 = date( 'd', $ts1 );
$day2 = date( 'd', $ts2 );
$month1_days = date( 't', $ts1 );
$month2_days = date( 't', $ts2 );
$d1 = new DateTime( date( 'Y-m-d', $ts1 ) );
$d2 = new DateTime( date( 'Y-m-d', strtotime( $fechaMAX .' +1 day') ) );
$diff = $d2->diff( $d1, true );
$month2_days = (int) date( 't ', $d2->getTimestamp() );
echo "$fechaMIN >> $fechaMAX >>>> " . date( 'Y-m-d ', $d1->getTimestamp() ) . ' >> ' . date( 'Y-m-d ', $d2->getTimestamp() ) ;
$diff_months = round( $diff->y * 12 + $diff->m + ( ( $diff->d ) / $month2_days ), 6 );
echo " >>> ". $diff_months .PHP_EOL;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 2011-01-01 >> 2012-05-31 >>>> 2011-01-01 >> 2012-06-01 >>> 17
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
2011-01-01 >> 2012-05-31 >>>> 2011-01-01 >> 2012-06-01 >>> 17
preferences:dark mode live preview
215.68 ms | 402 KiB | 236 Q