Home >Backend Development >PHP Tutorial >Example analysis of date and holiday conversion in php
A PHP date and holiday conversion class, convert the solar calendar to the lunar calendar, convert the lunar calendar to the solar calendar, obtain the year of the stems and branches, obtain the zodiac sign according to the lunar calendar year, obtain the number of days in each year of the lunar calendar, calculate the number of days between the lunar calendar date and the first day of the first lunar month, according to The lunar date is calculated as the number of days from the first day of the first lunar month.
The first step: Download the PHP date and holiday conversion library we need to use for this lesson: http://www.php.cn/xiazai/leiku/511
Second Step: After the download is completed, find the php class file, extract it to the local server, and create a new php file!
Step 3: We call this class in this new file and instantiate this class:
<?php include_once "date1.php";//引入类文件 $obj = new Lunar; //实例化 $year=2017; $month=8; $date=21; print_r($obj->convertSolarToLunar($year,$month,$date));//将阳历转换为阴历 //print_r($obj->convertSolarMonthToLunar($year,$month)); //print_r($obj->convertSolarMonthToLunar($year,$month)); //print_r($obj->convertLunarToSolar($year,$month,$date));//将阴历转换为阳历 //print_r($obj->getLunarYearDays($year)); //print_r($obj->getLunarByBetween($year,5)); ?>
##The running results are as shown below:
#Note:
Here we use a method, other friends can try it themselves~The above is the detailed content of Example analysis of date and holiday conversion in php. For more information, please follow other related articles on the PHP Chinese website!