Php calculates the age/Zodiac/Constellation instance based on the birthday

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.