0

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?

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Stefan_Lam88
0

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.

0

is a date function of phpmyadmin..not string

There are two differences.how do I convert?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.