Giter Site home page Giter Site logo

chanthornsp / carbonkh Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 28 KB

Covert date to Khmer lunar Date

Home Page: https://packagist.org/packages/chanthorn/carbon-kh

License: MIT License

PHP 100.00%
khmer khmer-calendar khmer-chhankitek-calendar khmer-lunar

carbonkh's Introduction

Khmer Lunar Date with Carbon

Installation

composer require chanthorn/carbon-kh

Usage

require_once __DIR__ . '/vendor/autoload.php';

use Carbon\Carbon;
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
    // ]

Use Helper Function

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

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

Authors

carbonkh's People

Contributors

chanthornsp avatar

Stargazers

 avatar

Watchers

 avatar

carbonkh's Issues

Class 'Carbon\\Carbon' not found

Hi! friend, why my code have error after the code start? It show that: PHP Fatal error: Uncaught Error: Class 'Carbon\Carbon' not found, and my code is:
require_once $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
use Carbon\Carbon;
use Chanthorn\CarbonKh\ToKhmerDate;
$date = Carbon::parse(strtotime($dateofWeek));
$khmerLunarDate = new ToKhmerDate($date);
echo $khmerLunarDate::format();
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.