Php calculates the age and zodiac constellation instance based on the birthday. This article introduces various program instance codes used to calculate the age and zodiac signs based on the year of birth, dear friends, please refer to the reference age calculation code below. copy the code function. This article introduces various program instance codes for age, Zodiac, and Constellation calculation based on the date of birth.
// Calculate the age
Function birthday ($ mydate) {$ birth = $ mydate; list ($ by, $ bm, $ bd) = explode ('-', $ birth ); $ cm = date ('N'); $ cd = date ('J'); $ age = date ('Y')-$ by-1; if ($ cm> $ bm | $ cm ==$ bm & $ cd> $ bd) $ age ++; return $ age; // echo "birthday: $ birthn age: $ agen ";}
Calculate the Chinese zodiac by year
Calculate constellation based on birthday
'Trease'), array ('19' => 'pisces '), array ('21' => 'Aries '), array ('20' => 'Taurus '), array ('21' => 'gemin'), array ('22' => 'rogen '), array ('23' => 'Leo '), array ('23' => 'virgo'), array ('23' => 'library '), array ('24' => 'Scorpio '), array ('22' => 'Sagittarius'), array ('22' => 'capricorn ')); $ key = (int) $ month-1; list ($ startSign, $ signName) = each ($ signs [$ key]); if ($ day <$ startSign) {$ key = $ month-2 <0? $ Month = 11: $ month-= 2; list ($ startSign, $ signName) = each ($ signs [$ key]);} return $ signName ;} echo get_constellation (12, 11); // Sagittarius echo get_constellation (6, 6); // Gemini
Related articles:
PHP calculates the age based on the birthday (Age)
Php age calculation based on birthday