asorasoft/chhankitek

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

Installs: 3 738

Dependents: 0

Suggesters: 0

Security: 0

Stars: 9

Watchers: 1

Forks: 8

Open Issues: 0

pkg:composer/asorasoft/chhankitek

2.0.1 2025-07-16 12:52 UTC

README

Latest Version on Packagist Total Downloads

A Laravel package to convert dates to Lunar (Chhankitek) format. Learn more about Khmer calendar.

πŸ‡°πŸ‡­ Stand with Cambodia β€’ αž€αž˜αŸ’αž–αž»αž‡αžΆ

πŸ•ŠοΈ 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

For detailed documentation, please visit https://chhankitek.netlify.app

Installation

You can install the package via composer:

composer require asorasoft/chhankitek

Usage

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

// Convert a date to lunar format
$toLunarDate = $this->chhankiteck(Carbon\CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh'));
$toLunarDate->toString(); // αžαŸ’αž„αŸƒαž…αŸαž“αŸ’αž‘ ៀ αžšαŸ„αž… αžαŸ‚αž”αž‹αž˜αžΆαžŸαžΆαž αž†αŸ’αž“αžΆαŸ†αž†αŸ’αž›αžΌαžœ αžαŸ’αžšαžΈαžŸαŸαž€ αž–αž»αž‘αŸ’αž’αžŸαž€αžšαžΆαž‡ ្αŸ₯៦αŸ₯

Available Methods

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

$toLunarDate = $this->chhankiteck(Carbon\CarbonImmutable::now()->setTimezone('Asia/Phnom_Penh'));

// 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')); // αžαŸ’αž„αŸƒαž…αŸαž“αŸ’αž‘ ៀ αžšαŸ„αž… αžαŸ‚αž”αž‹αž˜αžΆαžŸαžΆαž αž†αŸ’αž“αžΆαŸ†αž†αŸ’αž›αžΌαžœ αžαŸ’αžšαžΈαžŸαŸαž€ αž–αž»αž‘αŸ’αž’αžŸαž€αžšαžΆαž‡ ្αŸ₯៦αŸ₯

Caching

The Chhankitek package implements caching to improve performance when converting dates to lunar format. When you convert a date using the package, the result is cached for one year (365 days) to minimize computational overhead for frequently accessed dates.

How caching works

  • Each converted date is cached
  • Cache duration: 365 days (60 * 60 * 24 * 365 seconds)
  • The package leverages Laravel's cache system, so it will use whatever cache driver you've configured for your application

Testing

composer test

Changelog

Please see CHANGELOG for more information about recent changes.

Contributing

Please see CONTRIBUTING for details.

Security

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

Support

If you like this package and want to support me, you can buy me a coffee β˜•

Credits

License

The MIT License (MIT). Please see License File for more information.

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
  2. Ported from momentkh by ThyrithSor into Java
  3. Khmer New Year Time Calculation
  4. Ported from MetheaX/khmer-chhankitek-calendar by MetheaX into a Laravel Package