From 6ee767852a82a40be7e7672931ffee2058d765ad Mon Sep 17 00:00:00 2001 From: ChanthornAcademy Date: Fri, 1 Sep 2023 15:16:37 +0700 Subject: [PATCH] update doc --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 2a4b521..56bc471 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,44 @@ use Chanthorn\CarbonKh\ToKhmerDate; ``` +# Use Helper Function + +```php +require_once __DIR__ . '/vendor/autoload.php'; + +echo khmerDate('2024-01-01')->format(); +//ថ្ងៃច័ន្ទ ៥រោច ខែមិគសិរ ឆ្នាំថោះ បញ្ចស័ក ពុទ្ធសករាជ ២៥៦៧ + +print_r(khmerDate('2024-01-01')::khNewYear()); + +print_r(KhmerNewYearDate(2024)); +// array:3 [ +// "date" => Carbon\Carbon +// "days" => 4 +// "dates" => array:4 +// ] +``` + +# Usage with Laravel + +```php +use Chanthorn\CarbonKh\ToKhmerDate; + + $date = Carbon::parse('2023-01-01'); + $khmerDate = new ToKhmerDate($date); + + echo $khmerDate::format(); // ថ្ងៃអាទិត្យ ១០កើត ខែបុស្ស ឆ្នាំខាល ចត្វាស័ករាជ ២៥៦៦ + echo $khmerDate::format('dN ថ្ងៃW ខែm ព.ស. b'); // ១០កើត ថ្ងៃអាទិត្យ ខែបុស្ស ព.ស. ២៥៦៦ + + print_r($khmerDate::khNewYear()); + // array:3 [ + // "date" => Carbon\Carbon + // "days" => 3 + // "dates" => array:3 + // ] + +``` + ## Format Check out format [here](https://github.com/ThyrithSor/momentkh#format)