3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date1 = date_create("2012-01-01"); $date2 = date_create("2016-07-31"); $diff = date_diff($date1,$date2); echo $diff->format("%y yıl %m ay %d gün");
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14
4 yıl 6 ay 30 gün
Output for 5.4.12, 5.5.22, 5.6.0, 7.0.28, 7.3.32, 7.4.0 - 7.4.33, 8.0.1 - 8.0.30
4 yıl 6 ay 29 gün

preferences:
52.81 ms | 407 KiB | 5 Q