我在codeigniter视图中编写了一个php函数来计算出生日期的年龄。它适用于WAMP SERVER 2.4(PHP 5.4),但在WAMP SERVER 2.0(PHP 5.2)中显示错误。 我的代码,
function dob($dob)
{
$bday = new DateTime($dob);
$today = new DateTime('2013-11-08'); // for testing purposes
$bday = $today->diff($bday);
return $bday->y.' Years';
}
出现的错误,
Fatal error: Call to undefined method DateTime::diff() in C:\wamp\www\lamsapp\application\views\dm\form_tapal_app.php on line 80
请有人帮帮我..