Hi php developers,

I m new to php and would like to ask anything wrong with below script?

$year = (date('Y', time()) - date('Y', $model->DOB));

I m getting error as title shown.any one know the problem?

Member Avatar
diafol

echo $model->DOB to see the value

or even

$first = time();
$second = $model->DOB;

echo '(date(\'Y\', ' . $first . ') - date(\'Y\', ' . $second . '))';

That'll show you what's being passed.
It may be that you've got a string in the $model->DOB. Is this in a normal date format or is it in integer format? It should be a unix timestamp for this function to work.

is a date function of phpmyadmin..not string

There are two differences.how do I convert?