$birthday_ts = strtotime( get_field(\'dob\') );
$now = current_time( \'timestamp\' );
$years = intval( ( $now - $birthday_ts ) / YEAR_IN_SECONDS );
$months = intval( ( $now - $birthday_ts ) / MONTH_IN_SECONDS );
$weeks = intval( ( $now - $birthday_ts ) / WEEK_IN_SECONDS );
$days = intval( ( $now - $birthday_ts ) / DAY_IN_SECONDS );
$hours = intval( ( $now - $birthday_ts ) / HOUR_IN_SECONDS );
$minutes = intval( ( $now - $birthday_ts ) / MINUTE_IN_SECONDS );
$seconds = intval( ( $now - $birthday_ts ) );
echo $years . \' years | \' . $months . \' months | \' . $weeks . \' weeks | \' . $days . \' days | \' . $hours . \' hours | \' . $minutes . \' minutes | \' . $seconds . \' seconds\' ;
我只是用我自己的出生日期(1978年8月16日)试了一下,结果是:
39 years | 481 months | 2061 weeks | 14433 days | 346394 hours | 20783654 minutes | 1247019262 seconds