Celestial Earthly branches, referred to as "Ganzhi", this is the ancient Chinese calendar, the following use PHP to implement a Zodiac branch calculator, need friends can refer to the following
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. Zodiac algorithm 1 celestial stems and Earthly branches algorithm: one. After the year: 4 B 5 C 6 Ding 7 E 8 have 9 g 0 Xin 1 ren 2 3 such as the end of 1894 a number is 4 on a year, and so on earthly branches: Son 4 Ugly 5 Yin 6 Mao 7 8 have 9 10 not 11 Shen 0 unitary 1 Xu 2 hai 3 conversion: 1894 divided by 12, the remainder is a few, find a few two in the earthly branches. BC: Zodiac: a 7 B 6 C 5 ding 4 E 3 2 G 1 Xin 0 ren 9 8  ; such as 7 BC is a year and so on earthly: son-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, in the earthly branches to find a few generation Code as follows: <?php $TGDZ = Array (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."] ?> Zodiac Branch algorithm 2 code is as follows: <?php $TGDZ = Array (' g ', ' xin ', ' Ren ', ' gui ', ' a ', ' B ', ' C ', ' ding '), ' E ', ' self '), array(' Shen ', ' unitary ', ' Xu ', ' Hai ', ' son ', ' ugly ', ' ' Yin ', ' Mao ', ' Chen ', ' si ', ' afternoon ', ' not ')); for ($Year = 1900; $Year <= 2099 $Year + +) { $TianGanDiZhi = $TGDZ [0][$Year%]. $TGDZ [1][$Year%]; E Cho $Year. "Year is the lunar calendar [". $TianGanDiZhi. "] Year <br>"; }?>