This is a laravel package that converts English date to Nepali and vice versa.
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'
];
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.
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',
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.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.