PHPackages                             bobby/lunar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bobby/lunar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bobby/lunar
===========

阴阳历日期转换比较以及节假日判断和获取,使用简单

00PHP

Since Feb 18Pushed 6y agoCompare

[ Source](https://github.com/995933447/Lunar)[ Packagist](https://packagist.org/packages/bobby/lunar)[ RSS](/packages/bobby-lunar/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

阴阳历日期转换比较以及节假日判断和获取
===================

[](#阴阳历日期转换比较以及节假日判断和获取)

示例:判断是否传统节假日

```
    var_dump((new Lunar)->getFestival(2020, 01, 25));
    // OUTPUT
   /** array(4) {
      ["is"]=>
      bool(true)
      ["type"]=>
      int(0)
      ["info"]=>
      string(6) "春节"
      ["wish"]=>
      string(48) "春回大地风光好，福满人间喜事多。"
    }
    **/
```

- **public function convertSolarToLunar($year, $month, $date)**
    将阳历转换为阴历
    @param year 公历-年
    @param month 公历-月
    @param date 公历-日
- **public function convertLunarToSolar($year, $month, $date)**\\
    将阴历转换为阳历
    @param year 阴历-年
    @param month 阴历-月，闰月处理：例如如果当年闰五月，那么第二个五月就传六月，相当于阴历有13个月，只是有的时候第13个月的天数为0
    @param date 阴历-日
- **public function convertLunarToSolar($year, $month, $date)**
    将阴历转换为阳历
    @param year 阴历-年
    @param month 阴历-月，闰月处理：例如如果当年闰五月，那么第二个五月就传六月，相当于阴历有13个月，只是有的时候第13个月的天数为0
    @param date 阴历-日
- **public function isLeapYear($year)**
    判断是否是闰年
    @param year
- **public function getLunarYearName($year)**
    获取干支纪年
    @param year
- **public function getYearZodiac($year)**
    根据阴历年获取生肖
    @param year 阴历年
- **public function getSolarMonthDays($year, $month)**\\ 获取阳历月份的天数
    @param year 阳历-年
    @param month 阳历-月
- **public function getLunarMonthDays($year, $month)**
    获取阴历月份的天数
    @param year 阴历-年
    @param month 阴历-月，从一月开始
- **public function getLunarMonths($year)**
    获取阴历每月的天数的数组
    @param year
- **public function getLunarYearDays($year)**
    获取农历某年的天数
    @param year 农历年份
- **public function getLunarYearMonths($year)**
    获取农历某年的月数
    @param year 农历年份
- **public function getLeapMonth($year)**
    获取闰月
    @param year 阴历年份
- **public function getDaysBetweenLunar($year, $month, $date)**
    计算阴历日期与正月初一相隔的天数
    @param year
    @param month
    @param date
- **public function getDaysBetweenSolar($year, $cmonth, $cdate, $dmonth, $ddate)**
    计算2个阳历日期之间的天数
    @param year 阳历年
    @param cmonth
    @param cdate
    @param dmonth 阴历正月对应的阳历月份
    @param ddate 阴历初一对应的阳历天数
- **public function getLunarByBetween($year, $between)**
    根据距离正月初一的天数计算阴历日期
    @param year 阳历年
    @param between 天数
- **public function getCapitalNum($num, $isMonth)**
    获取数字的阴历叫法
    @param num 数字
    @param isMonth 是否是月份的数字
- **public function getFestival($year, $month, $day)**
    判断是否传统节假日

```
    var_dump((new Lunar)->getFestival(2020, 01, 25));
    // OUTPUT
   /** array(4) {
      ["is"]=>
      bool(true)
      ["type"]=>
      int(0)
      ["info"]=>
      string(6) "春节"
      ["wish"]=>
      string(48) "春回大地风光好，福满人间喜事多。"
    }
    **/
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d47cd9fa4ab8d80398000d29969d5d5f103dfdc2c37341bcb7b66e26f937a62c?d=identicon)[995933447](/maintainers/995933447)

### Embed Badge

![Health badge](/badges/bobby-lunar/health.svg)

```
[![Health](https://phpackages.com/badges/bobby-lunar/health.svg)](https://phpackages.com/packages/bobby-lunar)
```

###  Alternatives

[leafo/lessphp

lessphp is a compiler for LESS written in PHP.

2.2k8.2M141](/packages/leafo-lessphp)[realrashid/sweet-alert

Laravel Sweet Alert Is A Package For Laravel Provides An Easy Way To Display Alert Messages Using The SweetAlert2 Library.

1.2k2.9M21](/packages/realrashid-sweet-alert)[symfony/polyfill-php55

Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions

10731.7M9](/packages/symfony-polyfill-php55)[helmich/typo3-typoscript-lint

Static code analysis for the TypoScript configuration language.

902.9M241](/packages/helmich-typo3-typoscript-lint)[cyclonedx/cyclonedx-php-composer

Creates CycloneDX Software Bill-of-Materials (SBOM) from PHP Composer projects

821.6M17](/packages/cyclonedx-cyclonedx-php-composer)[kartik-v/yii2-widget-touchspin

A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes &amp; radios as toggle touchspines (sub repo split from yii2-widgets)

184.1M6](/packages/kartik-v-yii2-widget-touchspin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
