nisshan / nepali-calendar
It converts date from english to nepali and vice-versa
Fund package maintenance!
Nisshan
Requires
- php: ^8.0
- illuminate/contracts: ^8.73
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^5.10
- nunomaduro/larastan: ^1.0
- orchestra/testbench: ^6.22
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-03-29 01:11:32 UTC
README
This is a laravel package that converts English date to Nepali and vice versa.
Installation
You can install the package via composer:
composer require nisshan/nepali-calendar
You can publish the config file with:
php artisan vendor:publish --tag="nepali-calendar-config"
This is the contents of the published config file:
return [ 'date-format' => 'Y m, d is default format', 'nepali-dates' => 'array of nepali dates' ];
Usage
toNepaliDate('2022-1-17'); => '2078 10, 03' toNepaliDate('2022-1-17', 'Y, m d, D'); => '2078, 10 03, Monday'
to convert to Nepali Date from English and
toEnglishDate('2078-10-03'); => '2022 1, 17' toEnglishDate('2078-10-03', 'Y, m d, D'); => '2022, 1 17, Monday'
to convert to English from Nepali date. The date Format parameter is optional which format the date if not passed will be used from configuration file. The above two implements shows how you can pass the english date to the function with or without a separator that changes helps in separating the date using Helper file or you can also convert the date as
use Nisshan\NepaliCalendar\DateConversion; $nepaliDate = DateConversion::convert('2022-1-17')->toNepali(); $nepaliDateWithFormat = DateConversion::convert('2022-1-17','Y, m d, D')->toNepali(); $englishDate = DateConversion::convert('2078-10-03')->toNepali(); $englishWithFormat = DateConversion::convert('2078-10-03','Y, m d, D')->toNepali();
It will give same output as helper function.
Format that you can use
currently, I have used ['Y','M','D','d','m','y'] as date formatter you can use any combination of the following to output formatted date.
'Y','y' => 'Year', 'M' => 'Month Name', 'm' => 'month' 'D' => 'Name of Week Day', 'd' => 'date',
Thank you note
If you are here by any chance and using my package I would like to thank you and would love to accept PR on improvement of code or new features. Thank you.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.