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

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

bedlate/chinese-calendar
========================

中国农历转换与查询工具

0.1.1(7y ago)016MITPHPPHP &gt;=5.5.9

Since Apr 11Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bedlate/chinese-calendar)[ Packagist](https://packagist.org/packages/bedlate/chinese-calendar)[ RSS](/packages/bedlate-chinese-calendar/feed)WikiDiscussions master Synced today

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

Update
======

[](#update)

fork的[https://github.com/overtrue/chinese-calendar，修改五行的计算方式，修复每月最后一天23点的bug。](https://github.com/overtrue/chinese-calendar%EF%BC%8C%E4%BF%AE%E6%94%B9%E4%BA%94%E8%A1%8C%E7%9A%84%E8%AE%A1%E7%AE%97%E6%96%B9%E5%BC%8F%EF%BC%8C%E4%BF%AE%E5%A4%8D%E6%AF%8F%E6%9C%88%E6%9C%80%E5%90%8E%E4%B8%80%E5%A4%A923%E7%82%B9%E7%9A%84bug%E3%80%82)

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

[](#chinese-calendar)

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

Installing
==========

[](#installing)

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

Usage
=====

[](#usage)

```
use bedlate\ChineseCalendar\Calendar;

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

array (
  'lunar_year' => '2017',   // 农历年
  'lunar_month' => '04',    // 农历月
  'lunar_day' => '10',      // 农历日
  'lunar_hour' => '23',     // 农历时
  'lunar_year_chinese' => '二零一七',  // (汉字)农历年
  'lunar_month_chinese' => '四月',    // (汉字)农历月
  'lunar_day_chinese' => '初十',      // (汉字)农历日
  'lunar_hour_chinese' => '子时',     // (汉字)农历时辰
  'ganzhi_year' => '丁酉',            // (干支)年柱
  'ganzhi_month' => '乙巳',           // (干支)月柱
  'ganzhi_day' => '壬辰',             // (干支)日柱
  'ganzhi_hour' => '壬子',            // (干支)时柱
  'wuxing_year' => '火金',            // (五行)年
  'wuxing_month' => '木火',           // (五行)月
  'wuxing_day' => '水土',             // (五行)日
  'wuxing_hour' => '水水',            // (五行)时
  'color_year' => '红',              // (颜色)年
  'color_month' => '青',             // (颜色)月
  'color_day' => '黑',               // (颜色)日
  'color_hour' => '黑',              // (颜色)时
  'animal' => '鸡',                  // 生肖
  'term' => '立夏',                   // 节气
  '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)

License
=======

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.2% 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 ~57 days

Recently: every ~46 days

Total

13

Last Release

2627d ago

### Community

Maintainers

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

---

Top Contributors

[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (32 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)")[![bedlate](https://avatars.githubusercontent.com/u/11674510?v=4)](https://github.com/bedlate "bedlate (4 commits)")[![frowhy](https://avatars.githubusercontent.com/u/16863314?v=4)](https://github.com/frowhy "frowhy (1 commits)")[![blundering](https://avatars.githubusercontent.com/u/10548395?v=4)](https://github.com/blundering "blundering (1 commits)")[![pithyone](https://avatars.githubusercontent.com/u/8215934?v=4)](https://github.com/pithyone "pithyone (1 commits)")[![TinkoLiu](https://avatars.githubusercontent.com/u/24890691?v=4)](https://github.com/TinkoLiu "TinkoLiu (1 commits)")

---

Tags

calendarChineselunarsolarsolar2lunarlunar2solar

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/bedlate-chinese-calendar/health.svg)](https://phpackages.com/packages/bedlate-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)
