PHPackages                             asorasoft/chhankitek - 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. asorasoft/chhankitek

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

asorasoft/chhankitek
====================

Convert from AD (Anno Domini) to Lunar (Chhankitek) format.

2.2.1(3w ago)114.9k↑195.2%9MITPHPPHP ^8.2

Since Jun 29Pushed 3w ago1 watchersCompare

[ Source](https://github.com/HELMAB/chhankitek)[ Packagist](https://packagist.org/packages/asorasoft/chhankitek)[ Docs](https://github.com/HELMAB/chhankitek)[ RSS](/packages/asorasoft-chhankitek/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (23)Used By (0)

Chhankitek for Laravel
======================

[](#chhankitek-for-laravel)

 [![Latest Version on Packagist](https://camo.githubusercontent.com/ffe2da89b3459dda9524863a76217c8385c2ca9a1a4f980b4a15cb8999d76bb4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61736f7261736f66742f636868616e6b6974656b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asorasoft/chhankitek) [![Total Downloads](https://camo.githubusercontent.com/cb5e903c4c922b7a39f5d5343515d1202c03744ecea5a9d96d0d186a5e3da2aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61736f7261736f66742f636868616e6b6974656b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asorasoft/chhankitek) [![License](https://camo.githubusercontent.com/8f0ef3fbfcc30455cdcac5d6e3790a07ee62e0a5f6e311b1e6649342634271ce/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61736f7261736f66742f636868616e6b6974656b2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A PHP package to convert dates to Lunar (Chhankitek) format — works with or without Laravel. [Learn more about Khmer calendar](https://khmer-calendar.tovnah.com/calendar).

---

🇰🇭 Stand with Cambodia • កម្ពុជា
--------------------------------

[](#-stand-with-cambodia--កម្ពុជា)

### 🕊️ **Cambodia Needs Peace** 🕊️

[](#️-cambodia-needs-peace-️)

We stand in solidarity with our brave soldiers defending Cambodia's sovereignty and territorial integrity. Our hearts are with those protecting our homeland during these challenging times. We call upon the international community to support peaceful resolution and respect for Cambodia's borders.

**🙏 កម្ពុជាត្រូវការសន្តិភាព • Together we stand for peace and sovereignty**

---

Documentation
-------------

[](#documentation)

For detailed documentation, please visit

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

[](#installation)

You can install the package via composer:

```
composer require asorasoft/chhankitek
```

Usage
-----

[](#usage)

```
// In your Laravel controller, use this trait
use HasChhankitek;

// Convert a date to lunar format
$toLunarDate = $this->chhankitek(Carbon\CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh'));
$toLunarDate->toString(); // ថ្ងៃច័ន្ទ ៤ រោច ខែបឋមាសាឍ ឆ្នាំឆ្លូវ ត្រីស័ក ពុទ្ធសករាជ ២៥៦៥
```

> **Timezone note:** `->setTimezone('Asia/Phnom_Penh')` ensures the correct Cambodian **date** is used when your server runs in a different timezone (e.g. UTC). Near midnight UTC, the calendar date differs from Cambodia's. You can omit it if `app.timezone` in `config/app.php` is already set to `Asia/Phnom_Penh`.

Available Methods
-----------------

[](#available-methods)

```
// In your Laravel controller, use this trait
use HasChhankitek;

$toLunarDate = $this->chhankitek(Carbon\CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh')); // see timezone note above

// Get specific lunar date components
$toLunarDate->getDayOfWeek(); // អាទិត្យ, ច័ន្ទ...
$toLunarDate->getLunarDay(); // ១កើត, ២កើត...
$toLunarDate->getLunarMonth(); // ចេត្រ...
$toLunarDate->getLunarZodiac(); // ជូត, ឆ្លូវ...
$toLunarDate->getLunarEra(); // ត្រីស័ក...
$toLunarDate->getLunarYear(); // ២៥៦៥, ២៥៦៦..
```

Alternatively, you can use the `toLunarDate` helper function:

```
toLunarDate(Carbon\CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh')); // ថ្ងៃច័ន្ទ ៤ រោច ខែបឋមាសាឍ ឆ្នាំឆ្លូវ ត្រីស័ក ពុទ្ធសករាជ ២៥៦៥
```

Pure PHP Usage (without Laravel)
--------------------------------

[](#pure-php-usage-without-laravel)

The package works in any PHP project — Laravel is **not** required. The only runtime dependency is [`nesbot/carbon`](https://github.com/briannesbitt/Carbon).

```
composer require asorasoft/chhankitek
```

Instantiate `Chhankitek` directly and read the lunar date from the `formatKhmerDate` property:

```
require 'vendor/autoload.php';

use Asorasoft\Chhankitek\Chhankitek;
use Carbon\CarbonImmutable;

$target = CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh');

$toLunarDate = (new Chhankitek($target))->formatKhmerDate;

$toLunarDate->toString();      // ថ្ងៃច័ន្ទ ៤ រោច ខែបឋមាសាឍ ឆ្នាំឆ្លូវ ត្រីស័ក ពុទ្ធសករាជ ២៥៦៥
$toLunarDate->getLunarMonth(); // ចេត្រ...
$toLunarDate->getLunarYear();  // ២៥៦៥...
```

The `toLunarDate()` helper is also available outside Laravel:

```
toLunarDate(CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh'));
```

Khmer Numerals
--------------

[](#khmer-numerals)

Convert Arabic numerals to their Khmer representation with the `HasKhmerNumberConversion` trait:

```
use Asorasoft\Chhankitek\Traits\HasKhmerNumberConversion;

class SomeController
{
    use HasKhmerNumberConversion;

    public function index()
    {
        $this->convertToKhmerNumber(2569); // ២៥៦៩
        $this->convertToKhmerNumber('2025-05-11'); // ២០២៥-០៥-១១
    }
}
```

Caching
-------

[](#caching)

The package caches converted dates for one year (365 days) to minimize computational overhead for frequently accessed dates. The cache is **swappable** via the `CacheRepository` interface, so it works the same whether or not you use Laravel.

### Default behavior

[](#default-behavior)

- **Inside Laravel** — automatically uses Laravel's cache system (`LaravelCache`), so it respects whatever cache driver your application is configured with. No setup required.
- **Pure PHP** — falls back to an in-memory cache (`ArrayCache`) that de-duplicates lookups within a single request or script run.

### Providing your own cache

[](#providing-your-own-cache)

Pass any implementation of `Asorasoft\Chhankitek\Cache\CacheRepository` as the second constructor argument:

```
use Asorasoft\Chhankitek\Cache\ArrayCache;
use Asorasoft\Chhankitek\Cache\CacheRepository;
use Asorasoft\Chhankitek\Chhankitek;
use Carbon\CarbonImmutable;

// Use the bundled in-memory cache explicitly
$toLunarDate = (new Chhankitek($target, new ArrayCache))->formatKhmerDate;

// Or wire up your own (e.g. a PSR-16 adapter)
final class Psr16Cache implements CacheRepository
{
    public function __construct(private \Psr\SimpleCache\CacheInterface $cache) {}

    public function remember(string $key, int $ttl, callable $callback): mixed
    {
        if ($this->cache->has($key)) {
            return $this->cache->get($key);
        }

        $value = $callback();
        $this->cache->set($key, $value, $ttl);

        return $value;
    }
}

$toLunarDate = (new Chhankitek($target, new Psr16Cache($yourCache)))->formatKhmerDate;
```

Testing
-------

[](#testing)

```
composer test
```

The test suite is split into two groups — run them individually if needed:

```
vendor/bin/pest --testsuite=PurePhp  # framework-free tests (no Laravel)
vendor/bin/pest --testsuite=Laravel  # Laravel integration tests
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Support
-------

[](#support)

If you like this package and want to support me, you can [buy me a coffee ☕](https://www.buymeacoffee.com/helmab)

Credits
-------

[](#credits)

- [Mab Hel](https://github.com/asorasoft)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Authors and Acknowledgment
--------------------------

[](#authors-and-acknowledgment)

This library would not exist without the hard work of these people:

1. Based on the algorithm by `Mr. Phylypo Tum` from [Khmer Calendar](https://khmer-calendar.tovnah.com/calendar/chhankitek.php)
2. Ported from [momentkh](https://github.com/ThyrithSor/momentkh) by `ThyrithSor` into `Java`
3. [Khmer New Year Time Calculation](http://www.dahlina.com/education/khmer_new_year_time.html)
4. Ported from [MetheaX/khmer-chhankitek-calendar](https://github.com/MetheaX/khmer-chhankitek-calendar) by `MetheaX` into a `Laravel Package`

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 53.9% 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 ~138 days

Recently: every ~81 days

Total

14

Last Release

25d ago

Major Versions

1.0.10 → 2.0.02025-06-07

PHP version history (4 changes)1.0.3PHP ^7.2|^7.4|^8.0

1.0.5PHP ^7.2|^7.4|^8.0|^8.1

1.0.6PHP &gt;=7.2

2.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15307857?v=4)[ហ៊ែល ម៉ាប់](/maintainers/helmab)[@HELMAB](https://github.com/HELMAB)

---

Top Contributors

[![HELMAB](https://avatars.githubusercontent.com/u/15307857?v=4)](https://github.com/HELMAB "HELMAB (69 commits)")[![helmabio](https://avatars.githubusercontent.com/u/116546528?v=4)](https://github.com/helmabio "helmabio (47 commits)")[![putheakhem](https://avatars.githubusercontent.com/u/8064772?v=4)](https://github.com/putheakhem "putheakhem (7 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (4 commits)")[![lomhodev](https://avatars.githubusercontent.com/u/19190853?v=4)](https://github.com/lomhodev "lomhodev (1 commits)")

---

Tags

chankitichhankitekkhmerkhmer-calendarkhmer-chhankitek-calendarkhmerdatekhmerlunarlaravellunarasorasoftchhankitek

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/asorasoft-chhankitek/health.svg)

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

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M305](/packages/laravel-horizon)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)

PHPackages © 2026

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