Výpočet veku z dátumu narodenia PHP
public function age($birthdate) { $old = false; if ($birthdate < 0) { $birthdate = abs($birthdate); $old = true; } $birth = DateTime::createFromFormat('U', $birthdate); $age = ''; if ($birth->format('m') == date('m')) $age .= 'okolo '; if (!$old) $age .= $birth->diff(new DateTime('now'))->y; else { $epoch = new DateTime('1970-01-01'); $diff = $epoch->diff(new DateTime('now'))->y; $age .= $diff + $epoch->diff($birth)->y; } return $age; }