我正试图从ExpressionEngine网站上的出生日期计算出一个人的年龄。 以下代码适用于我的本地测试站点,但服务器正在使用较早版本的PHP(5.2.17),因此我不知所措。 有人可能会建议我需要使用什么代码吗?计算PHP的年龄5.2
{exp:channel:entries channel='zoo_visitor'}
<?php
$dob = new DateTime('{member_birthday format='%Y-%m-%d'}');
$now = new DateTime('now');
// This returns a DateInterval object.
$age = $now->diff($dob);
// You can output the date difference however you choose.
echo 'This person is ' .$age->format('%y') .' years old.';
?>
{/exp:channel:entries}
你有什么错误? – Adi