PHPackages                             guanhui07/chinese-calendar - 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. guanhui07/chinese-calendar

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

guanhui07/chinese-calendar
==========================

中国农历转换与查询工具

1.0.2(6y ago)013MITPHPPHP &gt;=5.5.9

Since Apr 11Pushed 1y agoCompare

[ Source](https://github.com/guanhui07/chinese-calendar)[ Packagist](https://packagist.org/packages/guanhui07/chinese-calendar)[ RSS](/packages/guanhui07-chinese-calendar/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (15)Used By (0)

Chinese calendar
================

[](#chinese-calendar)

📅 中国农历（阴历）与阳历（公历）转换与查询工具

Installing
==========

[](#installing)

```
$ composer require guanhui07/chinese-calendar -vvv
```

Usage
=====

[](#usage)

```
use Overtrue\ChineseCalendar\Calendar;

date_default_timezone_set('PRC');

$calendar = new Calendar();

$result = $calendar->solar(2017, 5, 5); // 阳历
$result = $calendar->lunar(2017, 4, 10); // 阴历
$result = $calendar->solar(2017, 5, 5, 23); // 阳历，带 $hour 参数
```

结果：

```
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,                 // (干支)时柱
    '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': '金牛'              // 星座
);

array (
  'lunar_year' => '2017',
  'lunar_month' => '04',
  'lunar_day' => '11',
  'lunar_hour' => '23',                  // 农历时
  'lunar_year_chinese' => '二零一七',
  'lunar_month_chinese' => '四月',
  'lunar_day_chinese' => '十一',
  'lunar_hour_chinese' => '子时',        // (汉字)农历时辰
  'ganzhi_year' => '丁酉',
  'ganzhi_month' => '乙巳',
  'ganzhi_day' => '癸巳',
  'ganzhi_hour' => '壬子',               // (干支)日柱
  'animal' => '鸡',
  'term' => NULL,
  'is_leap' => false,
  'gregorian_year' => '2017',
  'gregorian_month' => '05',
  'gregorian_day' => '05',
  'gregorian_hour' => '23',              // 公历时
  'week_no' => 5,
  'week_name' => '星期五',
  'is_today' => false,
  'constellation' => '金牛',
);
```

> 你可能注意到，含时间的农历结果怎么是 `四月十一` 而不是 `四月初十`，具体见 #13

更多 API 请查看源码。

Reference
=========

[](#reference)

- [1900年至2100年公历、农历互转Js代码 - 晶晶的博客](http://blog.jjonline.cn/userInterFace/173.html) - 数据与部分算法来源
- [中国历法 - 维基百科](https://zh.wikipedia.org/wiki/Category:%E4%B8%AD%E5%9B%BD%E5%8E%86%E6%B3%95)
- [农历 - 维基百科](https://zh.wikipedia.org/wiki/%E8%BE%B2%E6%9B%86)
- [阴历 - 维基百科](https://zh.wikipedia.org/wiki/%E9%98%B4%E5%8E%86)
- [阳历 - 维基百科](https://zh.wikipedia.org/wiki/%E9%98%B3%E5%8E%86)
- [干支 - 维基百科](https://zh.wikipedia.org/wiki/%E5%B9%B2%E6%94%AF)
- [星座 - 维基百科](https://zh.wikipedia.org/wiki/%E6%98%9F%E5%BA%A7)
- [生肖 - 维基百科](https://zh.wikipedia.org/wiki/%E7%94%9F%E8%82%96)

PHP 扩展包开发
---------

[](#php-扩展包开发)

> 想知道如何从零开始构建 PHP 扩展包？
>
> 请关注我的实战课程，我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)

License
=======

[](#license)

MIT

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~81 days

Recently: every ~139 days

Total

14

Last Release

2255d ago

Major Versions

0.0.11 → 1.0.02019-03-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/3abde3fccf025ce86670101d7cfa0641d2415c9daad93e5f0c9573a2b23ddbda?d=identicon)[guanhui07](/maintainers/guanhui07)

---

Top Contributors

[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (39 commits)")[![hao-li](https://avatars.githubusercontent.com/u/11334645?v=4)](https://github.com/hao-li "hao-li (10 commits)")[![consatan](https://avatars.githubusercontent.com/u/1174105?v=4)](https://github.com/consatan "consatan (5 commits)")[![guanhui07](https://avatars.githubusercontent.com/u/5820457?v=4)](https://github.com/guanhui07 "guanhui07 (4 commits)")[![jiangzhenhong](https://avatars.githubusercontent.com/u/18389186?v=4)](https://github.com/jiangzhenhong "jiangzhenhong (1 commits)")[![pithyone](https://avatars.githubusercontent.com/u/8215934?v=4)](https://github.com/pithyone "pithyone (1 commits)")[![summerblue](https://avatars.githubusercontent.com/u/324764?v=4)](https://github.com/summerblue "summerblue (1 commits)")[![alphasnow](https://avatars.githubusercontent.com/u/8286647?v=4)](https://github.com/alphasnow "alphasnow (1 commits)")[![TinkoLiu](https://avatars.githubusercontent.com/u/24890691?v=4)](https://github.com/TinkoLiu "TinkoLiu (1 commits)")[![bedlate](https://avatars.githubusercontent.com/u/11674510?v=4)](https://github.com/bedlate "bedlate (1 commits)")[![blundering](https://avatars.githubusercontent.com/u/10548395?v=4)](https://github.com/blundering "blundering (1 commits)")[![frowhy](https://avatars.githubusercontent.com/u/16863314?v=4)](https://github.com/frowhy "frowhy (1 commits)")

---

Tags

calendarChineselunarsolarsolar2lunarlunar2solar

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/guanhui07-chinese-calendar/health.svg)

```
[![Health](https://phpackages.com/badges/guanhui07-chinese-calendar/health.svg)](https://phpackages.com/packages/guanhui07-chinese-calendar)
```

###  Alternatives

[overtrue/chinese-calendar

中国农历转换与查询工具

557103.7k4](/packages/overtrue-chinese-calendar)[eluceo/ical

The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your \*.ics file by hand. The output will follow RFC 5545 as best as possible.

1.2k17.5M47](/packages/eluceo-ical)[spatie/icalendar-generator

Build calendars in the iCalendar format

6787.4M9](/packages/spatie-icalendar-generator)[6tail/lunar-php

lunar是一款无第三方依赖的日历工具，支持公历(阳历)、农历(阴历、老黄历)、佛历和道历，支持星座、儒略日、干支、生肖、节气、节日、彭祖百忌、每日宜忌、吉神宜趋、凶煞宜忌、吉神(喜神/福神/财神/阳贵神/阴贵神)方位、胎神方位、冲煞、纳音、星宿、八字、五行、十神、建除十二值星、青龙名堂等十二神、黄道日及吉凶等。lunar is a calendar library for Solar and Chinese Lunar.

19326.3k4](/packages/6tail-lunar-php)[phpu/calendar

中国日历，通过天文计算和民间推算方法，准确计算出公历-1000年至3000年的农历、干支、节气等，同时支持多配置、多语言、多时区。

201.7k](/packages/phpu-calendar)[moe/full-calendar

A lightweight calendar module for Silverstripe. Implements the popular javascript http://fullcalendar.io/ library.

121.5k](/packages/moe-full-calendar)

PHPackages © 2026

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