PHPackages                             pphatdev/lunar-date - 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. pphatdev/lunar-date

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

pphatdev/lunar-date
===================

A PHP library for converting Gregorian dates to Khmer (Cambodian) calendar dates and vice versa, inspired by momentkh

v0.1.2(9mo ago)1351MITPHPPHP &gt;=7.4CI passing

Since Aug 6Pushed 9mo agoCompare

[ Source](https://github.com/pphatdev/lunar-date)[ Packagist](https://packagist.org/packages/pphatdev/lunar-date)[ Docs](https://github.com/pphatdev/lunar-date)[ RSS](/packages/pphatdev-lunar-date/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Lunar Date - PHP Khmer Calendar Library
=======================================

[](#lunar-date---php-khmer-calendar-library)

[![CI](https://github.com/pphatdev/lunar-date/workflows/CI/badge.svg)](https://github.com/pphatdev/lunar-date/actions)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/6eff5053a32c9e0bcc0982c4f118ef689cad7831a3d982767aae3901bf67313c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e342d626c75652e737667)](https://php.net)[![Latest Stable Version](https://camo.githubusercontent.com/78c1166b4a4523c31fad62670a93514b0559def6f77299389b93d613c6b9fb60/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70706861746465762f6c756e61722d646174652e737667)](https://packagist.org/packages/pphatdev/lunar-date)[![Total Downloads](https://camo.githubusercontent.com/b1977d3476b26f1e401f93faad39df87d1fba21c0fb1f337febb3bb5104cd2e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70706861746465762f6c756e61722d646174652e737667)](https://packagist.org/packages/pphatdev/lunar-date)

A comprehensive PHP library for converting between Gregorian and Khmer (Cambodian) calendar dates. This is a faithful port of the popular JavaScript [momentkh](https://github.com/ThyrithSor/momentkh) library by ThyrithSor, enhanced with modern PHP best practices and comprehensive testing.

Features
--------

[](#features)

### Core Calendar Functions

[](#core-calendar-functions)

- ✅ **Gregorian to Khmer Lunar Date Conversion** - Full bidirectional date conversion with lunar calendar support
- ✅ **Buddhist Era (BE) Year Support** - Accurate BE year calculations and conversion utilities
- ✅ **Khmer New Year Calculations** - Precise calculation of Khmer New Year moments using advanced algorithms
- ✅ **Animal Year System** - Complete 12-year animal cycle (ឆ្នាំសត្វ) support
- ✅ **Era Year System** - 10-year era cycle (ស័ក) calculations
- ✅ **Leap Year Support** - Accurate lunar calendar leap year handling

### Formatting &amp; Localization

[](#formatting--localization)

- ✅ **Flexible Date Formatting** - Customizable output with Khmer formatting tokens
- ✅ **Number Conversion** - Bidirectional Arabic ↔ Khmer numeral conversion
- ✅ **Khmer Text Support** - Full Unicode Khmer character support and validation
- ✅ **Multiple Calendar Systems** - Solar and lunar month name support

### Developer Experience

[](#developer-experience)

- ✅ **Modern PHP (7.4+)** - Strict types, comprehensive type hints, and modern syntax
- ✅ **Comprehensive Testing** - Full PHPUnit test suite with edge case coverage
- ✅ **Static Analysis** - PHPStan ready with high code quality standards
- ✅ **PSR-12 Standards** - Follows PHP coding standards and best practices
- ✅ **Rich Documentation** - Detailed PHPDoc annotations and usage examples

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- ext-json (usually included)

Installation
------------

[](#installation)

Install via Composer:

```
composer require pphatdev/lunar-date
```

Quick Start
-----------

[](#quick-start)

```
