内部循环运行的PHP函数不起作用(带代码)

I am running this function

function Age($month, $day, $year) {
    date_default_timezone_set('America/New_York');
    $dob = $month .''. $day .''. $year;
    $startDate = strtotime($dob);
    $endDate = time();
    $dif = $endDate - $startDate;

    return $years = (date('Y', $dif) - 1970) .' y, '. ($months = date('n', $dif) - 1).' m';
}

inside a foreach loop (some CodeIgniter markup):

foreach ($users as $row) {
    echo $this->includes->Age($row->birth_month, $row->birth_day, $row->birth_year)
  }

The loop works OK, showing all my users.

But the problem is that it calculates the age correctly for the first user and then shows that same age for all other users. I should point out that all other user's data is correct, only the age is wrong.

Anyone know how to fix this?

Thanks!

Your $dob looks malformed. Try $dob = $year . '-' . $month . '-' $day;

Maybe CI is caching the result?
Seems that function Age is correct

You're missing space/separators.

$dob = $month .''. $day .''. $year;

should be

$dob = $month .'/'. $day .'/'. $year;

edit: Ambiguity. If using mm-dd-yyyy format, should be /

. and - indicate dd-mm-yyyy