3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on D7RWU
Output for 7.1.0 - 7.2.0
Notice: A non well formed numeric value encountered in /in/Ii2DF on line 7 Notice: A non well formed numeric value encountered in /in/Ii2DF on line 7 0 years, 0 months, 0 days 0 numberDays
Output for 5.5.0 - 7.0.20
0 years, 0 months, 0 days 0 numberDays