在PHP中,计算一个人的周岁可以通过获取当前日期和该人的出生日期来计算。以下是一个简单的PHP实例,展示如何计算一个人的周岁。
```php

// 定义出生年月日
$birthDate = '1990-06-15';
// 获取当前日期
$currentDate = date('Y-m-d');
// 将字符串日期转换为时间戳
$birthTimestamp = strtotime($birthDate);
$currentTimestamp = strtotime($currentDate);
// 计算两个时间戳的差值(单位为秒)
$ageInSeconds = $currentTimestamp - $birthTimestamp;
// 将秒转换为周岁
$ageInYears = $ageInSeconds / (60 * 60 * 24 * 365);
// 四舍五入周岁
$ageInYears = round($ageInYears);
echo "




