Home > Mobile >  How to get list of people those are more than 40 year old in PHP Codeigniter
How to get list of people those are more than 40 year old in PHP Codeigniter

Time:12-30

Hi I am calculating age of the people in Codeigniter by their Date of Birth. I want to Separate the people where age is more than 40 years. I have used the simple condition if($age>40){my code block} but it does not work for those whose age is 40 years and month>0 or you may say 40 years and 0 month and days>0 is their any built-in function in CodeIgniter for this purpose or any solution..? thanks in advance...

CodePudding user response:

It also depends on where you get the age data from. Is it stored as 40 years, 2 months or is that a calculation made from a birth date? Did you try if ($age >= 40) ?

CodePudding user response:

here is my solution that works for me if age is 40 and month is greater than 0 or day is greater than 0.

if ($ageyear > 40 || ($ageyear == 40 && ($agemonth > 0 || $agedays > 0))) {
$isOverAge = "Over age";
}

   
  • Related