This article mainly introduces the age Calculation Method of php Based on birthday. It involves related skills related to php operation date and string. It is very simple and practical. For more information, see
This article mainly introduces the age Calculation Method of php Based on birthday. It involves related skills related to php operation date and string. It is very simple and practical. For more information, see
This example describes how to calculate the age of a birthday in php. Share it with you for your reference. The details are as follows:
<? Php function birthday ($ birthday) {$ age = strtotime ($ birthday); if ($ age = false) {return false;} list ($ y1, $ m1, $ d1) = explode ("-", date ("Y-m-d", $ age); $ now = strtotime ("now"); list ($ y2, $ m2, $ d2) = explode ("-", date ("Y-m-d", $ now); $ age = $ y2-$ y1; if (int) ($ m2. $ d2) <(int) ($ m1. $ d1) $ age-= 1; return $ age ;} echo birthday ('2017-07-22 ');?>
I hope this article will help you with php programming.
,