3v4l.org

run code in 300+ PHP versions simultaneously
<?php //create both dates (birthday and today). $birthday = date_create($this->birthday); $today = date_create(date('Y-m-d')); //check if the dates are valid. if (($birthday !== false && $today !== false) && ($birthday < $today)) { return date_diff($birthday, $today)->y; } else { return -1; }

preferences:
40.85 ms | 402 KiB | 5 Q