PHP Lunar-lunar-convert class code _php instance

Source: Internet
Author: User
Tags echo date

Copy Code code as follows:



<?php


/**


* Public lunar conversion (1912-2012)


*


* Usage:


*//Gregorian calendar 1983-10-5 turn lunar calendar


* $lunar = new lunar ();


* $date = $lunar->getlar (' 1983-10-5 ', 0);


* Echo Date ("y-m-d", $date);


*//Lunar calendar 1983-8-29 to Gregorian


* $date = $lunar->getlar (' 1983-8-29 ', 1);


* Echo Date ("y-m-d", $date);


*


* @param string Date


* @param int Date Calendar


*-0 Gregorian calendar


* 1 Lunar Calendar


*


* @return Timestamp


This is a national calendar and the lunar calendar with each other to turn the unit.

These years are in the Republic year, please convert (Siyuanyan-1911 = Year of the Republic).


***************************************************************************


* Description of the National Lunar Mapping table: *


***************************************************************************


* top two digits = Leap month, if 13, no leap month *


* Third to sixth digit = 12 month size month 2 carry code->10 carry *


* For example: *


* 101010101010 = 2730 *


* 1: On behalf of Semi-rotary (30 days) 0: On behalf of the Moon (29 days) ==> January big February small March big. *


* The seventh digit is the leap month days *


* 0: No days of LEAP month *


* 1: Leap month for Xiao (29 days) *


* 2: Leap month for Semi-rotary (30 days) *


* The last 2 digits represent the Gregorian calendar January 1 and the lunar Calendar January 1 Difference days *


***************************************************************************


This reflects only the Republic of China 1 to the Republic of 1, if not enough for your use, please follow the above way to increase yourself.

This program does not determine whether you entered the year, month, day is correct, please judge for yourself.

If the month of the converted lunar calendar is a leap, the value to you is negative * * * *
If the lunar calendar is to be converted into a leap month, please enter * * * negative

This version is freeware version:0.1
You can modify it yourself, but it is best to send me a copy of the modified program.
If you want to use for commercial purposes, please mail me to tell you the purpose and reason.

*/
Class Lunar {
var $LMDay = array ();
var $InterMonth = 0;
var $InterMonthDays = 0;
var $SLRangeDay = 0;

var $SMDay = Array (1 => 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


var $LongLife = Array (1 =>


' 132637048 ', ' 133365036 ', ' 053365225 ', ' 132900044 ', ' 131386034 ', ' 022778122 ',//6


' 132395041 ', ' 071175231 ', ' 131175050 ', ' 132635038 ', ' 052891127 ', ' 131701046 ',//12


' 131748035 ', ' 042741223 ', ' 130694043 ', ' 132391032 ', ' 021327122 ', ' 131175040 ',//18


' 061623129 ', ' 133402047 ', ' 133402036 ', ' 051769125 ', ' 131453044 ', ' 130694034 ',//24


' 032158223 ', ' 132350041 ', ' 073213230 ', ' 133221049 ', ' 133402038 ', ' 063466226 ',//30


' 132901045 ', ' 131130035 ', ' 042651224 ', ' 130605043 ', ' 132349032 ', ' 023371121 ',//36


' 132709040 ', ' 072901128 ', ' 131738047 ', ' 132901036 ', ' 051333226 ', ' 131210044 ',//42


' 132651033 ', ' 031111223 ', ' 131323042 ', ' 082714130 ', ' 133733048 ', ' 131706038 ',//48


' 062794127 ', ' 132741045 ', ' 131206035 ', ' 042734124 ', ' 132647043 ', ' 131318032 ',//54


' 033878120 ', ' 133477039 ', ' 071461129 ', ' 131386047 ', ' 132413036 ', ' 051245126 ',//60


' 131197045 ', ' 132637033 ', ' 043405122 ', ' 133365041 ', ' 083413130 ', ' 132900048 ',//66


' 132922037 ', ' 062394227 ', ' 132395046 ', ' 131179035 ', ' 042711124 ', ' 132635043 ',//72


' 102855132 ', ' 131701050 ', ' 131748039 ', ' 062804128 ', ' 132742047 ', ' 132359036 ',//78


' 051199126 ', ' 131175045 ', ' 131611034 ', ' 031866122 ', ' 133749040 ', ' 081717130 ',//84


' 131452049 ', ' 132742037 ', ' 052413127 ', ' 132350046 ', ' 133222035 ', ' 043477123 ',//90


' 133402042 ', ' 133493031 ', ' 021877121 ', ' 131386039 ', ' 072747128 ', ' 130605048 ',//96


' 132349037 ', ' 053243125 ', ' 132709044 ', ' 132890033 ');





function Getlar ($date, $isLunar = 1) {


List ($year, $month, $day) = Split ("-", $date);


if ($isLunar = = 1)


return $this->lunar2solar ($year, $month, $day);


Else


return $this->solar2lunar ($year, $month, $day);


}





function Isleapyear ($AYear) {


Return ($AYear% 4 = 0) and ($AYear% <> 0) or ($AYear% 400 = 0));


}





function Covertlunarmonth ($MAGICNO) {


$m = $magicno;


for ($i = $i >= 1; $i-) {


$size = $m% 2;


if ($size = = 0)


$this->lmday[$i] = 29;


Else


$this->lmday[$i] = 30;


$m = Floor ($m/2);


}


}





function Processmagicstr ($yy) {


$yy = $yy-1911;


$magicstr = $this->longlife[$yy];


$this->intermonth = substr ($magicstr, 0, 2);


$LunarMonth = substr ($magicstr, 2, 4);


$this->covertlunarmonth ($LunarMonth);


$dsize = substr ($magicstr, 6, 1);


Switch ($dsize) {


Case 0:


$this->intermonthdays = 0;


Break


Case 1:


$this->intermonthdays = 29;


Break


Case 2:


$this->intermonthdays = 30;


Break


}


$this->slrangeday = substr ($magicstr, 7, 2);


}





function Daysperlunarmonth ($LYear, $LMonth) {


$this->processmagicstr ($LYear);


if ($LMonth < 0)


return $this->intermonthdays;


Else


return $this->lmday[$LMonth];


}





function Solar2lunar ($SYear, $SMonth, $SDay) {


if (!) ( 1912 <= $SYear && $SYear <= 2012)) {


return false;


}


$day = 0;


if ($this->isleapyear ($SYear))


$this->smday[2] = 29;


$this->processmagicstr ($SYear);


if ($SMonth = = 1)


$day = $SDay;


else {


for ($i = 1; $i <= $SMonth-1; $i + +)


$day = $day + $this->smday[$i];


$day = $day + $SDay;


}


if ($day <= $this->slrangeday) {


$day = $day-$this->slrangeday;


$this->processmagicstr ($SYear-1);


for ($i = $i >= 1; $i-) {


$day = $day + $this->lmday[$i];


if ($day > 0)


Break


}


$LYear = $SYear-1;


$LMonth = $i;


$LDay = $day;


} else {


$day = $day-$this->slrangeday;


for ($i = 1; $i <= $this->intermonth-1; $i + +) {


$day = $day-$this->lmday[$i];


if ($day <= 0)


Break


}


if ($day <= 0) {


$LYear = $SYear;


$LMonth = $i;


$LDay = $day + $this->lmday[$i];


} else {


$day = $day-$this->lmday[$this->intermonth];


if ($day <= 0) {


$LYear = $SYear;


$LMonth = $this->intermonth;


$LDay = $day + $this->lmday[$this->intermonth];


} else {


$this->lmday[$this->intermonth] = $this->intermonthdays;


for ($i = $this->intermonth; $i <= $i + +) {


$day = $day-$this->lmday[$i];


if ($day <= 0)


Break


}


if ($i = = $this->intermonth)


$LMonth = 0-$this->intermonth;


Else


$LMonth = $i;


$LYear = $SYear;


$LDay = $day + $this->lmday[$i];


}


}


}


Return mktime (0, 0, 0, $LMonth, $LDay, $LYear);


}





function Lunar2solar ($LYear, $LMonth, $LDay) {


if (!) ( 1912 <= $LYear && $LYear <= 2012)) {


return false;


}


$day = 0;


$SYear = $LYear;


if ($this->isleapyear ($SYear))


$this->smday[2] = 29;


$this->processmagicstr ($SYear);


if ($LMonth < 0)


$day = $this->lmday[$this->intermonth];


if ($LMonth <> 1)


for ($i = 1; $i <= $LMonth-1; $i + +)


$day = $day + $this->lmday[$i];


$day = $day + $LDay + $this->slrangeday;


if ($this->intermonth <>) and ($this->intermonth < $LMonth))


$day = $day + $this->intermonthdays;


for ($i = 1; $i <= $i + +) {


$day = $day-$this->smday[$i];


if ($day <= 0)


Break


}


if ($day > 0) {


$SYear = $SYear + 1;


if ($this->isleapyear ($SYear))


$this->smday[2] = 29;


for ($i = 1; $i <= $i + +) {


$day = $day-$this->smday[$i];


if ($day <= 0)


Break


}


}


$day = $day + $this->smday[$i];


$SMonth = $i;


$SDay = $day;


Return mktime (0, 0, 0, $SMonth, $SDay, $SYear);


}


}


?>





How to use:


Copy Code code as follows:

$lunar = new Lunar ();
$date = $lunar->getlar (' 1983-10-5 ', 0);
echo Date ("y-m-d", $date);
Lunar 1983-8-29 to Gregorian calendar
$date = $lunar->getlar (' 1983-8-29 ', 1);
echo Date ("y-m-d", $date);







Copy Code code as follows:



<?php


Class Lunar {


var $MIN _year = 1891;


var $MAX _year = 2100;


var $lunarInfo = Array (


Array (0,2,9,21936), Array (6,1,30,9656), Array (0,2,17,9584), Array (0,2,6,21168), Array (5,1,26,43344), Array ( 0,2,13,59728),


Array (0,2,2,27296), Array (3,1,22,44368), Array (0,2,10,43856), Array (8,1,30,19304), Array (0,2,19,19168), Array ( 0,2,8,42352),


Array (5,1,29,21096), Array (0,2,16,53856), Array (0,2,4,55632), Array (4,1,25,27304), Array (0,2,13,22176), Array ( 0,2,2,39632),


Array (2,1,22,19176), Array (0,2,10,19168), Array (6,1,30,42200), Array (0,2,18,42192), Array (0,2,6,53840), Array ( 5,1,26,54568),


Array (0,2,14,46400), Array (0,2,3,54944), Array (2,1,23,38608), Array (0,2,11,38320), Array (7,2,1,18872), Array ( 0,2,20,18800),


Array (0,2,8,42160), Array (5,1,28,45656), Array (0,2,16,27216), Array (0,2,5,27968), Array (4,1,24,44456), Array ( 0,2,13,11104),


Array (0,2,2,38256), Array (2,1,23,18808), Array (0,2,10,18800), Array (6,1,30,25776), Array (0,2,17,54432), Array ( 0,2,6,59984),


Array (5,1,26,27976), Array (0,2,14,23248), Array (0,2,4,11104), Array (3,1,24,37744), Array (0,2,11,37600), Array ( 7,1,31,51560),


Array (0,2,19,51536), Array (0,2,8,54432), Array (6,1,27,55888), Array (0,2,15,46416), Array (0,2,5,22176), Array ( 4,1,25,43736),


Array (0,2,13,9680), Array (0,2,2,37584), Array (2,1,22,51544), Array (0,2,10,43344), Array (7,1,29,46248), Array ( 0,2,17,27808),


Array (0,2,6,46416), Array (5,1,27,21928), Array (0,2,14,19872), Array (0,2,3,42416), Array (3,1,24,21176), Array ( 0,2,12,21168),


Array (8,1,31,43344), Array (0,2,18,59728), Array (0,2,8,27296), Array (6,1,28,44368), Array (0,2,15,43856), Array ( 0,2,5,19296),


Array (4,1,25,42352), Array (0,2,13,42352), Array (0,2,2,21088), Array (3,1,21,59696), Array (0,2,9,55632), Array ( 7,1,30,23208),


Array (0,2,17,22176), Array (0,2,6,38608), Array (5,1,27,19176), Array (0,2,15,19152), Array (0,2,3,42192), Array ( 4,1,23,53864),


Array (0,2,11,53840), Array (8,1,31,54568), Array (0,2,18,46400), Array (0,2,7,46752), Array (6,1,28,38608), Array ( 0,2,16,38320),


Array (0,2,5,18864), Array (4,1,25,42168), Array (0,2,13,42160), Array (10,2,2,45656), Array (0,2,20,27216), Array ( 0,2,9,27968),


Array (6,1,29,44448), Array (0,2,17,43872), Array (0,2,6,38256), Array (5,1,27,18808), Array (0,2,15,18800), Array ( 0,2,4,25776),


Array (3,1,23,27216), Array (0,2,10,59984), Array (8,1,31,27432), Array (0,2,19,23232), Array (0,2,7,43872), Array ( 5,1,28,37736),


Array (0,2,16,37600), Array (0,2,5,51552), Array (4,1,24,54440), Array (0,2,12,54432), Array (0,2,1,55888), Array ( 2,1,22,23208),


Array (0,2,9,22176), Array (7,1,29,43736), Array (0,2,18,9680), Array (0,2,7,37584), Array (5,1,26,51544), Array ( 0,2,14,43344),


Array (0,2,3,46240), Array (4,1,23,46416), Array (0,2,10,44368), Array (9,1,31,21928), Array (0,2,19,19360), Array ( 0,2,8,42416),


Array (6,1,28,21176), Array (0,2,16,21168), Array (0,2,5,43312), Array (4,1,25,29864), Array (0,2,12,27296), Array ( 0,2,1,44368),


Array (2,1,22,19880), Array (0,2,10,19296), Array (6,1,29,42352), Array (0,2,17,42208), Array (0,2,6,53856), Array ( 5,1,26,59696),


Array (0,2,13,54576), Array (0,2,3,23200), Array (3,1,23,27472), Array (0,2,11,38608), Array (11,1,31,19176), Array ( 0,2,19,19152),


Array (0,2,8,42192), Array (6,1,28,53848), Array (0,2,15,53840), Array (0,2,4,54560), Array (5,1,24,55968), Array ( 0,2,12,46496),


Array (0,2,1,22224), Array (2,1,22,19160), Array (0,2,10,18864), Array (7,1,30,42168), Array (0,2,17,42160), Array ( 0,2,6,43600),


Array (5,1,26,46376), Array (0,2,14,27936), Array (0,2,2,44448), Array (3,1,23,21936), Array (0,2,11,37744), Array ( 8,2,1,18808),


Array (0,2,19,18800), Array (0,2,8,25776), Array (6,1,28,27216), Array (0,2,15,59984), Array (0,2,4,27424), Array ( 4,1,24,43872),


Array (0,2,12,43744), Array (0,2,2,37600), Array (3,1,21,51568), Array (0,2,9,51552), Array (7,1,29,54440), Array ( 0,2,17,54432),


Array (0,2,5,55888), Array (5,1,26,23208), Array (0,2,14,22176), Array (0,2,3,42704), Array (4,1,23,21224), Array ( 0,2,11,21200),


Array (8,1,31,43352), Array (0,2,19,43344), Array (0,2,7,46240), Array (6,1,27,46416), Array (0,2,15,44368), Array ( 0,2,5,21920),


Array (4,1,24,42448), Array (0,2,12,42416), Array (0,2,2,21168), Array (3,1,22,43320), Array (0,2,9,26928), Array ( 7,1,29,29336),


Array (0,2,17,27296), Array (0,2,6,44368), Array (5,1,26,19880), Array (0,2,14,19296), Array (0,2,3,42352), Array ( 4,1,24,21104),


Array (0,2,10,53856), Array (8,1,30,59696), Array (0,2,18,54560), Array (0,2,7,55968), Array (6,1,27,27472), Array ( 0,2,15,22224),


Array (0,2,5,19168), Array (4,1,25,42216), Array (0,2,12,42192), Array (0,2,1,53584), Array (2,1,21,55592), Array ( 0,2,9,54560)


);


/**


* Convert Gregorian calendar to lunar calendar


* @param year Gregorian calendar-years


* @param month Gregorian calendar-month


* @param date Gregorian calendar-day


*/


function Convertsolartolunar ($year, $month, $date) {


Debugger


$yearData = $this->lunarinfo[$year-$this->min_year];


if ($year = = $this->min_year&& $month <=2&& $date <=9) {


Return Array (1891, ' First month ', ' first grade ', ' Xin Mao ', 1, 1, ' Rabbit ');


}


return $this->getlunarbybetween ($year, $this->getdaysbetweensolar ($year, $month, $date, $yearData [1],$ YEARDATA[2]));


}





function Convertsolarmonthtolunar ($year, $month) {


$yearData = $this->lunarinfo[$year-$this->min_year];


if ($year = = $this->min_year&& $month <=2&& $date <=9) {


Return Array (1891, ' First month ', ' first grade ', ' Xin Mao ', 1, 1, ' Rabbit ');


}


$month _days_ary = Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);


$DD = $month _days_ary[$month];


if ($this->isleapyear ($year) && $month = 2) $dd + +;


$lunar _ary = Array ();


for ($i = 1; $i < $DD; $i + +) {


$array = $this->getlunarbybetween ($year, $this->getdaysbetweensolar ($year, $month, $i, $yearData [1], $yearData [ 2]));


$array [] = $year. '-' . $month. '-' . $i;


$lunar _ary[$i] = $array;


}


return $lunar _ary;


}


/**


* Convert the lunar calendar to the Gregorian calendar


* @param year lunar calendar-years


* @param month lunar calendar-month, Leap Moon processing: For example, if the year of May, then the second May on the June, the equivalent of the lunar calendar has 13 months, but sometimes the 13th month of the number of days is 0


* @param date Lunar calendar-day


*/


function Convertlunartosolar ($year, $month, $date) {


$yearData = $this->lunarinfo[$year-$this->min_year];


$between = $this->getdaysbetweenlunar ($year, $month, $date);


$res = Mktime (0,0,0, $yearData [1], $yearData [2], $year);


$res = Date (' y-m-d ', $res + $between *24*60*60);


$day = Explode ('-', $res);


$year = $day [0];


$month = $day [1];


$day = $day [2];


Return Array ($year, $month, $day);


}


/**


* Judging whether it's a leap year


* @param year


*/


function Isleapyear ($year) {


Return ($year%4==0 && $year%100!=0) | | ($year%400==0));


}


/**


* Access to Ganzhi Annals


* @param year


*/


function Getlunaryearname ($year) {


$sky = Array (' Geng ', ' xin ', ' Ren ', ' gui ', ' a ', ' B ', ' C ', ' ding ', ' e ', ' self ');


$earth = Array (' shen ', ' unitary ', ' Xu ', ' Hai ', ' son ', ' ugly ', ' ' Yin ', ' Mao ', ' Chen ', ' si ', ' afternoon ', ' not ');


$year = $year.


return $sky [$year {3}]. $earth [$year%12];


}


/**


* According to lunar year to get the zodiac


* @param year Overcast calendar years


*/


function Getyearzodiac ($year) {


$zodiac = Array (' monkey ', ' chicken ', ' dog ', ' pig ', ' rat ', ' ox ', ' tiger ', ' Rabbit ', ' dragon ', ' snake ', ' horse ', ' sheep ');


return $zodiac [$year%12];


}


/**


* Get the number of days in the Gregorian calendar month


* @param year Gregorian calendar-years


* @param month Gregorian calendar-month


*/


function Getsolarmonthdays ($year, $month) {


$monthHash = Array (' 1 ' =>31, ' 2 ' => $this->isleapyear ($year)? 29:28, ' 3 ' =>31, ' 4 ' =>30, ' 5 ' =>31, ' 6 ' = >30, ' 7 ' =>31, ' 8 ' =>31, ' 9 ' =>30, ' =>31 ', ' One ' =>30, ' =>31 ';


return $monthHash ["$month"];


}


/**


* Get the number of days of lunar month


* @param year lunar calendar-years


* @param month lunar calendar-month, starting from January


*/


function Getlunarmonthdays ($year, $month) {


$monthData = $this->getlunarmonths ($year);


return $monthData [$month-1];


}


/**


* Get an array of the days of the lunar month


* @param year


*/


function Getlunarmonths ($year) {


$yearData = $this->lunarinfo[$year-$this->min_year];


$leapMonth = $yearData [0];


$bit = Decbin ($yearData [3]);


for ($i = 0; $i < strlen ($bit); $i + +) {


$bitArray [$i] = substr ($bit, $i, 1);


}


For ($k =0, $klen =16-count ($bitArray); $k < $klen; $k + +) {


Array_unshift ($bitArray, ' 0 ');


}


$bitArray = Array_slice ($bitArray, 0, ($leapMonth ==0?12:13));


for ($i =0; $i <count ($bitArray); $i + +) {


$bitArray [$i] = $bitArray [$i] + 29;


}


return $bitArray;


}


/**


* Get the number of days of lunar calendar year


* @param year lunar calendar


*/


function Getlunaryeardays ($year) {


$yearData = $this->lunarinfo[$year-$this->min_year];


$monthArray = $this->getlunaryearmonths ($year);


$len = count ($monthArray);


Return ($monthArray [$len -1]==0 $monthArray [$len-2]: $monthArray [$len-1]);


}


function Getlunaryearmonths ($year) {


Debugger


$monthData = $this->getlunarmonths ($year);


$res =array ();


$temp = 0;


$yearData = $this->lunarinfo[$year-$this->min_year];


$len = ($yearData [0]==0?12:13);


for ($i =0; $i < $len; $i + +) {


$temp = 0;


for ($j =0; $j <= $i; $j + +) {


$temp + + $monthData [$j];


}


Array_push ($res, $temp);


}


return $res;


}


/**


* Get Leap month


* @param year Lunar


*/


function Getleapmonth ($year) {


$yearData = $this->lunarinfo[$year-$this->min_year];


return $yearData [0];


}


/**


* Calculate the number of days between the lunar date and the first month


* @param year


* @param month


* @param date


*/


function Getdaysbetweenlunar ($year, $month, $date) {


$yearMonth = $this->getlunarmonths ($year);


$res = 0;


for ($i =1; $i < $month; $i + +) {


$res + + $yearMonth [$i-1];


}


$res + + $date-1;


return $res;


}


/**


* Calculate the number of days between 2 Gregorian dates


* @param year Sun


* @param cmonth


* @param cdate


* @param dmonth the Gregorian calendar month corresponding to the lunar month


* @param ddate the Gregorian calendar days corresponding to the day


*/


function Getdaysbetweensolar ($year, $cmonth, $cdate, $dmonth, $ddate) {


$a = Mktime (0,0,0, $cmonth, $cdate, $year);


$b = Mktime (0,0,0, $dmonth, $ddate, $year);


Return Ceil (($a-$b)/24/3600);


}


/**


* Calculate the lunar date based on the number of days from the first month


* @param year Sun


* @param between Days


*/


function Getlunarbybetween ($year, $between) {


Debugger


$lunarArray = Array ();


$yearMonth =array ();


$t = 0;


$e = 0;


$leapMonth = 0;


$m = ';


if ($between ==0) {


Array_push ($lunarArray, $year, ' first month ', ' first grade ');


$t = 1;


$e = 1;


}else{


$year = $between >0? $year: ($year-1);


$yearMonth = $this->getlunaryearmonths ($year);


$leapMonth = $this->getleapmonth ($year);


$between = $between >0 $between: ($this->getlunaryeardays ($year) + $between);


For ($i =0 $i <13; $i + +) {


if ($between = = $yearMonth [$i]) {


$t = $i +2;


$e = 1;


Break


}else if ($between < $yearMonth [$i]) {


$t = $i +1;


$e = $between-(Empty ($yearMonth [$i-1])? 0: $yearMonth [$i-1]) +1;


Break


}


}


$m = ($leapMonth!=0&& $t = = $leapMonth + 1)? (' Leap '. $this->getcapitalnum ($t -1,true)): $this->getcapitalnum ($leapMonth!=0&& $leapMonth +1< $t? ( $t-1): $t), true);


Array_push ($lunarArray, $year, $m, $this->getcapitalnum ($e, false));


}


Array_push ($lunarArray, $this->getlunaryearname ($year));


Array_push ($lunarArray, $t, $e);


Array_push ($lunarArray, $this->getyearzodiac ($year));//12 Zodiac


Array_push ($lunarArray, $leapMonth);//leap for a few months


return $lunarArray;


}


/**


* Get the number of the lunar name


* @param num Numbers


* @param Ismonth is the number of months


*/


function Getcapitalnum ($num, $isMonth) {


$isMonth = $isMonth | | False


$dateHash =array (' 0 ' => ', ' 1 ' => ' one ', ' 2 ' => ' II ', ' 3 ' => ' III ', ' 4 ' => ' Four ', ' 5 ' => ', ' 6 ' => ', ' 7 ', ' => ', ' seven ' , ' 8 ' => ' eight ', ' 9 ' => ' nine ', ' => ' ten ');


$monthHash =array (' 0 ' => ', ' 1 ' => ', ' 2 ' => ' February ', ' 3 ' => ' March ', ' 4 ' => ' April ', ' 5 ' => ' May ', ' 6 ' => ' June ', ' 7 ' = > ' July ', ' 8 ' => ' August ', ' 9 ' => ' September ', ' => ' October ', ' One ' => ' winter months ', ' => '.


$res = ';


if ($isMonth) {


$res = $monthHash [$num];


}else{


if ($num <=10) {


$res = ' early '. $dateHash [$num];


}else if ($num >10&& $num <20) {


$res = ' ten '. $dateHash [$num-10];


}else if ($num ==20) {


$res = "20";


}else if ($num >20&& $num <30) {


$res = "20". $dateHash [$num-20];


}else if ($num ==30) {


$res = "30";


}


}


return $res;


}


}


$lunar = new Lunar ();


$month = $lunar->convertlunartosolar (2012, 1,1);


Print_r ($month);


Exit


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.