how to calculate age from date of birth in php and mysql

how to calculate age from date of birth in php and mysql – Calculate age from date of birth in php or Age calculator code in PHP Example.

how to calculate age from date of birth in php and mysql?

In the following code, date(), date_create(), and date_diff() functions are used to calculate age of the members till today in PHP.

SELECT id, (DATEDIFF(CURRENT_DATE, STR_TO_DATE(dob, ‘%Y-%m-%d’))/365) as age FROM `members`

How to Calculate Age from Date of Birth in PHP?

format('%y');
?>

Age calculator code in PHP

format('%yYears, %mMonths, %dDays');
}

echo getAge('25-04-2003');
?>

Don’t miss : How To Calculate Age From Date Of Birth In PHP?

Calculate age from date of birth column using mysql query

SELECT 
        id,
  (DATEDIFF(CURRENT_DATE, STR_TO_DATE(dob, '%Y-%m-%d'))/365) as age 

FROM `members`

I hope you get an idea about how to calculate age from date of birth in php and mysql.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment