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?

Recommended Answers

All 3 Replies

Member Avatar for 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?

problem solved thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.