我已经搜索过这个但没有在php中找到一个完美的函数。我想要一个仅以月为单位计算人的年龄的php函数。例如:lessthenonemonthold.5monthsold.340monthsold.谢谢 最佳答案 使用PHP的DateInterval(从5.3.0开始可用),这很简单:$birthday=newDateTime('1990-10-13');$diff=$birthday->diff(newDateTime());$months=$diff->format('%m')+12*$diff->format('%y');现在$m