PHP implementation of the Zodiac and Earthly Branches Calculator example _php instance

Source: Internet
Author: User

Heavenly stems and earthly branches, referred to as "Ganzhi". In the ancient Chinese calendar, a, B, C, Ding, E, oneself, Geng, Xin, Ren, GUI is known as "10 days dry", son, Ugly, my colleagues, Mao, Chen, Si, Wu, not, Shen, unitary, Xu, Hai is called "12 Earthly Branches." The ten-stem and 12-in-one matching, composed of 60 basic units, the two in a fixed sequence of each other, composed of the Ganzhi-ji law. From the Oracle inscriptions unearthed in the ruins, the heavenly stems and earthly branches were mainly used in ancient China, in addition to Guile, Annals, Guixi and so on.

Heavenly stems and Earthly branches algorithm 1

Celestial stems and Earthly branches algorithm:

I. Post-A.D.:
Zodiac: a 4 B 5 c 6 Ding 7 E 8 have 9 g 0 Xin 1 ren 2
such as the end of 1894 a number is 4 on a year, and so on

Earthly branches: 4 Ugly 5, 6, 7, 8, 9, not 10, 11, 0, 1, and 2.
Conversion: 1894 divided by 12, the remainder is a few, just find a few in the earthly branches

Two. BC:
Zodiac: a 7 B 6 C 5 ding 4 E 3 have 2 G 1 Xin 0 ren 9
such as 7 BC is a year and so forth

Earthly Branches: 9 Ugly-8-7-6-5-4-afternoon-3 not-2 Shen-1 unitary 0 XU-11 hai-10
Conversion: such as 221 BC, 221 divided by 12, the remainder is a few, find a few in the earthly branches

Copy Code code as follows:

<?php
$TGDZ = Array (' A ', ' B ', ' C ', ' ding ', ' e ', ' self ', ' Geng ', ' xin ', ' Ren ', ' gui '),
Array (' son ', ' ugly ', ' I ', ' Mao ', ' Chen ', ' si ', ' afternoon ', ' not ', ' shen ', ' unitary ', ' Xu ', ' Hai '));
$Year = 2014;
$Year _jisuan = $Year-1900 + 36;
$TianGanDiZhi = $TGDZ [0][$Year _jisuan% 10]. $TGDZ [1][$Year _jisuan% 12];
echo $Year. " Year for lunar calendar [". $TianGanDiZhi."] Years ";
?>

Heavenly stems and Earthly branches algorithm 2

Copy Code code as follows:

<?php
$TGDZ = Array (' Geng ', ' Xin ', ' siren ', ' GUI ', ' a ', ' B ', ' C ', ' ding ', ' e ', ' self ', array (' Shen ', ' unitary ', ' Xu ', ' Hai ', ' son ', ' ugly ', ' ", ' Chen ', ' si ', ' afternoon ', ' not ');
for ($Year = 1900; $Year <= 2099; $Year + +)
{
$TianGanDiZhi = $TGDZ [0][$Year% 10]. $TGDZ [1][$Year% 12];
Echo $Year. "Year is the lunar calendar [". $TianGanDiZhi. "] Year <br>";
}
?>

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.