我想用出生日期计算人的月龄加上几天(例如:1986-08-23).
例如:
0 months and 25 days old. 5 months and 20 days old. 150 months and 4 days old. 285 months and 30 days old.
任何的想法?谢谢.
$date = new DateTime('1990-10-13'); $diff = $date->diff(new DateTime()); printf("%d months and %d days old",$diff->y*12 + $diff->m,$diff->d);
请注意,DateTime::diff()
需要PHP 5.3.0或更高版本.