Is there a way to calculate the age of the user in PHP or from MySQL directly without using so many vars? I mean, what is the shortest code/way ?
In MySQL the date is stored like this: 2010-12-26 using DATE
The PHP is working like this:
<?php
$birthday = new DateTime($result['birthday']);
$now = new DateTime();
$age = $now->diff($birthday);
echo $age -> y;
?>
My question is if it is possible to shorten this for example like this:
<?php
echo new DateTime()->diff->$row['birthday'] -> y;
?>