PHP code example of nyg / holiday

1. Go to this page and download the library: Download nyg/holiday 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/ */

    

nyg / holiday example snippets

 php
use nyg\Holiday;

$holiday=new holiday();

$result = $holiday->isHoliday(time());


$result = $holiday->isHoliday(time(),Holiday::TYPE_VACATION);

$result = $holiday->count(strtotime('2020-1-1'),strtotime('2020-12-30'),Holiday::TYPE_VACATION);
// 返回30

$result = $holiday->countDate(strtotime('2020-1-1'),strtotime('2020-3-1'),Holiday::TYPE_VACATION);
//返回数组
["2020-01-01","2020-01-24","2020-01-25","2020-01-26","2020-01-27","2020-01-28","2020-01-29","2020-01-30","2020-01-31","2020-02-01","2020-02-02"]

$result = $holiday->getLunar(strtotime('2020-10-1'));
// 返回数组 
[
    "year" => "2020",
    "month" => "8",
    "day" => "15",
    "lmonth" => "八",
    "ldate" => "十五",
    "gz_year" => "庚子",
    "gz_month" => "乙酉",
    "gz_date" => "丁丑",
]