{"id":13792944,"url":"https://github.com/overtrue/chinese-calendar","last_synced_at":"2025-05-15T17:07:09.732Z","repository":{"id":41186820,"uuid":"87433094","full_name":"overtrue/chinese-calendar","owner":"overtrue","description":":date: 中国农历（阴历）与阳历（公历）转换与查询工具","archived":false,"fork":false,"pushed_at":"2023-01-29T01:59:28.000Z","size":75,"stargazers_count":535,"open_issues_count":17,"forks_count":111,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-07T22:09:18.150Z","etag":null,"topics":["calendar","chinese","lunar","lunar2solar","solar","solar2lunar"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overtrue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-06T13:34:34.000Z","updated_at":"2025-03-20T09:25:46.000Z","dependencies_parsed_at":"2023-02-15T20:05:21.143Z","dependency_job_id":null,"html_url":"https://github.com/overtrue/chinese-calendar","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fchinese-calendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fchinese-calendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fchinese-calendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fchinese-calendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overtrue","download_url":"https://codeload.github.com/overtrue/chinese-calendar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384987,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calendar","chinese","lunar","lunar2solar","solar","solar2lunar"],"created_at":"2024-08-03T22:01:18.695Z","updated_at":"2025-05-15T17:07:04.724Z","avatar_url":"https://github.com/overtrue.png","language":"PHP","funding_links":[],"categories":["PHP","类库"],"sub_categories":["时间/日期"],"readme":"# Chinese calendar\n\n:date: 中国农历（阴历）与阳历（公历）转换与查询工具\n\n# Installing\n\n```shell\n$ composer require overtrue/chinese-calendar -vvv\n```\n\n# Usage\n\n```php\nuse Overtrue\\ChineseCalendar\\Calendar;\n\ndate_default_timezone_set('PRC'); \n\n$calendar = new Calendar();\n\n$result = $calendar-\u003esolar(2017, 5, 5); // 阳历\n$result = $calendar-\u003elunar(2017, 4, 10); // 阴历\n$result = $calendar-\u003esolar(2017, 5, 5, 23) // 阳历，带 $hour 参数\n\n```\n\n结果：\n\n```php\narray(\n    'lunar_year': '2017',                // 农历年\n    'lunar_month': '04',                 // 农历月\n    'lunar_day': '10',                   // 农历日\n    'lunar_hour': NULL,                  // 农历时\n    'lunar_year_chinese': '二零一七',    // (汉字)农历年\n    'lunar_month_chinese': '四月',       // (汉字)农历月\n    'lunar_day_chinese': '初十',         // (汉字)农历日\n    'lunar_hour_chinese': NULL,          // (汉字)农历时辰\n    'ganzhi_year': '丁酉',               // (干支)年柱\n    'ganzhi_month': '乙巳',              // (干支)月柱\n    'ganzhi_day': '壬辰',                // (干支)日柱\n    'ganzhi_hour': NULL,                 // (干支)时柱\n    'animal': '鸡',                      // 生肖\n    'term': '立夏',                      // 节气\n    'is_leap': false,                    // 是否为闰月\n    'gregorian_year': '2017',            // 公历年\n    'gregorian_month': '05',             // 公历月\n    'gregorian_day': '05',               // 公历日\n    'gregorian_hour': NULL,              // 公历时\n    'week_no': 5,                        // (数字)星期几\n    'week_name': '星期五',               // (汉字)星期几\n    'is_today': false,                   // 是否为今天\n    'constellation': '金牛'              // 星座\n);\n\narray (\n  'lunar_year' =\u003e '2017',\n  'lunar_month' =\u003e '04',\n  'lunar_day' =\u003e '11',\n  'lunar_hour' =\u003e '23',                  // 农历时\n  'lunar_year_chinese' =\u003e '二零一七',\n  'lunar_month_chinese' =\u003e '四月',\n  'lunar_day_chinese' =\u003e '十一',\n  'lunar_hour_chinese' =\u003e '子时',        // (汉字)农历时辰\n  'ganzhi_year' =\u003e '丁酉',\n  'ganzhi_month' =\u003e '乙巳',\n  'ganzhi_day' =\u003e '癸巳',\n  'ganzhi_hour' =\u003e '壬子',               // (干支)日柱\n  'animal' =\u003e '鸡',\n  'term' =\u003e NULL,\n  'is_leap' =\u003e false,\n  'gregorian_year' =\u003e '2017',\n  'gregorian_month' =\u003e '05',\n  'gregorian_day' =\u003e '05',\n  'gregorian_hour' =\u003e '23',              // 公历时\n  'week_no' =\u003e 5,\n  'week_name' =\u003e '星期五',\n  'is_today' =\u003e false,\n  'constellation' =\u003e '金牛',\n);\n```\n\n\u003e 你可能注意到，含时间的农历结果怎么是 `四月十一` 而不是 `四月初十`，具体见 #13\n\n更多 API 请查看源码。\n\n# Reference\n\n- [1900年至2100年公历、农历互转Js代码 - 晶晶的博客](http://blog.jjonline.cn/userInterFace/173.html) - 数据与部分算法来源\n- [中国历法 - 维基百科](https://zh.wikipedia.org/wiki/Category:%E4%B8%AD%E5%9B%BD%E5%8E%86%E6%B3%95)\n- [农历 - 维基百科](https://zh.wikipedia.org/wiki/%E8%BE%B2%E6%9B%86)\n- [阴历 - 维基百科](https://zh.wikipedia.org/wiki/%E9%98%B4%E5%8E%86)\n- [阳历 - 维基百科](https://zh.wikipedia.org/wiki/%E9%98%B3%E5%8E%86)\n- [干支 - 维基百科](https://zh.wikipedia.org/wiki/%E5%B9%B2%E6%94%AF)\n- [星座 - 维基百科](https://zh.wikipedia.org/wiki/%E6%98%9F%E5%BA%A7)\n- [生肖 - 维基百科](https://zh.wikipedia.org/wiki/%E7%94%9F%E8%82%96)\n\n## PHP 扩展包开发\n\n\u003e 想知道如何从零开始构建 PHP 扩展包？\n\u003e\n\u003e 请关注我的实战课程，我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fchinese-calendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovertrue%2Fchinese-calendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fchinese-calendar/lists"}