PHP code example of overtrue / chinese-calendar

1. Go to this page and download the library: Download overtrue/chinese-calendar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

overtrue / chinese-calendar example snippets


use Overtrue\ChineseCalendar\Calendar;

$calendar = new Calendar();

$result = $calendar->solar(2017, 5, 5);     // 公历 -> 农历
$result = $calendar->lunar(2017, 4, 10);    // 农历 -> 公历
$result = $calendar->solar(2017, 5, 5, 23); // 带小时参数(23 点按晚子时归入次日)

array(
    'lunar_year' => '2017',              // 农历年
    'lunar_month' => '04',               // 农历月
    'lunar_day' => '10',                 // 农历日
    'lunar_hour' => NULL,                // 农历时
    'lunar_year_chinese' => '二零一七',   // (汉字)农历年
    'lunar_month_chinese' => '四月',      // (汉字)农历月
    'lunar_day_chinese' => '初十',        // (汉字)农历日
    'lunar_hour_chinese' => NULL,        // (汉字)农历时辰
    'ganzhi_year' => '丁酉',             // (干支)年柱
    'ganzhi_month' => '乙巳',            // (干支)月柱
    'ganzhi_day' => '壬辰',              // (干支)日柱
    'ganzhi_hour' => NULL,               // (干支)时柱
    'wuxing_year' => '火金',             // (五行)年
    'wuxing_month' => '木火',            // (五行)月
    'wuxing_day' => '水土',              // (五行)日
    'wuxing_hour' => NULL,               // (五行)时
    'color_year' => '红',                // (颜色)年
    'color_month' => '青',               // (颜色)月
    'color_day' => '黑',                 // (颜色)日
    'color_hour' => NULL,                // (颜色)时
    'animal' => '鸡',                    // 生肖
    'term' => '立夏',                    // 节气
    'is_leap' => false,                  // 是否为闰月
    'gregorian_year' => '2017',          // 公历年
    'gregorian_month' => '05',           // 公历月
    'gregorian_day' => '05',             // 公历日
    'gregorian_hour' => NULL,            // 公历时
    'week_no' => 5,                      // (数字)星期几
    'week_name' => '星期五',             // (汉字)星期几
    'is_today' => false,                 // 是否为今天
    'constellation' => '金牛',           // 星座
    'is_same_year' => true,              // 农历年与公历年是否同年
);