Basically I was trying to get age from date of birth, for which I am using Computed Field
module.
Following code was used:
$isoArray = explode ( '-', substr($entity->field_dob1[0]['value'],0,10));
$bdayunix = mktime ( 00, 00, 00, (int)$isoArray[1], (int)$isoArray[2], (int)$isoArray[0]);
$nowunix = time();
$unixage = $nowunix - $bdayunix;
$age = floor($unixage/ (365 * 24 * 60 * 60));
$entity_field[0]['value'] = $age;
When I checked the code, I found that this part of code is not giving the correct result:
$isoArray = explode ( '-', substr($entity->field_dob1[0]['value'],0,10));
$bdayunix = mktime ( 00, 00, 00, (int)$isoArray[1], (int)$isoArray[2], (int)$isoArray[0]);
I can say that because when I try to convert $bdayunix into date,whatever the date of birth is, I always get the result 1999.
ie; $dob = date("Y",$bdayunix ); always gives result:1999.
Could you please tell me where I am going wrong? Is this problem of Computed field module or I am doing some mistake in my code ?
(Date format in users bday field is yyyy-mm-dd and I have tried all types: Date, DateISO format and Date Unix timestamp).
Thank you in advance.