PHP calculates age/Zodiac/constellation instances based on birthdays

Source: Internet
Author: User
This article describes the user's birth date to calculate the age/Zodiac/constellation of various program instance code, friends do not enter the reference

Calculate 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"; }

The zodiac is calculated by year

<?php/**  *  calculation. Zodiac  *   * @param int $year Year  * @return str *  /function Get_animal ($year) { c13/> $animals = Array (             ' rat ', ' ox ', ' tiger ', ' Rabbit ', ' dragon ', ' Snake ', '              horse ', ' sheep ', ' monkey ', ' chicken ', ' dog ', ' pig '     );     $key = ($year -1900)%;     return $animals [$key]; }echo Get_animal (1990);    Ma Echo get_animal ();    Tiger

Calculate constellations based on birthdays

<?php/**  *  calculation. Constellation  *  * @param int $month month  * @param int $day Date  * @return str */  function g Et_constellation ($month, $day) {$signs = array (' + ' = ' Aquarius '), Array (' + ' = ' pisces             '),             Array (' (' = ' + ' aries '), Array (' + ' = ' Taurus '), Array (' + ' + ' Gemini '), Array (' + ' + '             cancer '), array (' + ' = ')             Leo '), Array (' + ' = ' virgo '), array (' + ' = ' libra '), Array (' ' + ' = ' Scorpio '), Array (' + ' + '             sagittarius '), Array (' + ' = ' capricorn ')     ;     $key = (int) $month-1;     List ($startSign, $signName) = each ($signs [$key]);     if ($day < $startSign) {         $key = $month-2 < 0? $month = one: $month-= 2;         List ($startSign, $signName) = each ($signs [$key]);     }     return $signName; }echo Get_constellation (a);    Sagittarius Echo get_constellation (6, 6);      Gemini

Related articles:

PHP based on birthday calculation age (years)

How PHP calculates age based on birthdays

  • Related Article

    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.