PHP如何计算出四柱八字,Github有个源码叫做calendar,使用这个PHP源码可以计算出精准无误的四柱八字

源码支持阳历和阴历计算八字,很完美。


阳历计算代码:

<?php
$calendar = new Calendar();
//阳历
$result = $calendar->solar(date('Y'),date('m'),date('d'),date('H')); 
print_r($result);
?>


阴历计算:

<?php
$calendar = new Calendar();
//输入的阳历日期时间
$result = $calendar->lunar(date('Y'),date('m'),date('d'),date('H')); 
print_r($result);
?>

用阳历计算四柱:

<?php
$calendar = new Calendar();
$result = $calendar->solar(date('Y'),date('m'),date('d'),date('H')); 
echo $result['ganzhi_year'].','.$result['ganzhi_month'].','.$result['ganzhi_day'].','.$result['ganzhi_hour'];
?>

结果:

壬寅,戊申,癸卯,癸亥

阴历计算四柱:

<?php
$calendar = new Calendar();
$result = $calendar->lunar(2022,7,18,false,4); // 阴历
echo $result['ganzhi_year'].','.$result['ganzhi_month'].','.$result['ganzhi_day'].','.$result['ganzhi_hour'];
?>

用lunar函数的时候第四个输入bool类型,表示月份是否是闰月

下载地址:

Github:https://github.com/overtrue/chinese-calendar

蓝奏云:https://ityh.lanzoub.com/ijylV09s8e0f

百度网盘: https://pan.baidu.com/s/1v10l-xJdaW8rLQLRYDN3Sw 提取码: xb27

- END -


文章链接:https://www.ityinhu.com/702.html

作者邮箱:ponyj@qq.com