nutandc / nepali-date-converter
Nepali Date Converter (BS <-> AD) for Nepal-first date conversion.
Package info
github.com/Nutandc/Nepali-BS-AD-Date-Converter
pkg:composer/nutandc/nepali-date-converter
v1.1.3
2026-01-03 01:21 UTC
Requires
- php: ^8.2
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.92
- phpunit/phpunit: ^10.0
README
A lightweight PHP package to convert Nepali Bikram Sambat (BS) dates to Gregorian (AD) and vice versa.
Requirements
- PHP 8.2+
- Laravel 10+ (optional, for container binding)
Installation
composer require nutandc/nepali-date-converter
Usage
use Nutandc\NepaliDateConverter\DateConverter; use Nutandc\NepaliDateConverter\Enums\EnglishDateFormat; use Nutandc\NepaliDateConverter\Enums\NepaliDateFormat; $converter = new DateConverter(); // AD to BS $bs = $converter->toNepali(2020, 10, 4); $bs->toDateString(); // 2077-06-18 $bs->toFormattedEnglish(); // 18 Ashoj 2077, Sunday $bs->toFormattedNepali(); // २०७७ असोज १८, आइतवार $bs->toArray(); // ['year' => 2077, 'month' => 6, 'day' => 18, 'day_of_week' => 1] $bs->toFormattedArray(); // ['year' => '२०७७', 'month' => 'असोज', 'day' => '१८', 'day_of_week' => 'आइतवार'] // AD to BS using DateTime/Carbon $bs = $converter->toNepaliFromDateTime(new DateTimeImmutable('2022-09-08')); // BS to AD $ad = $converter->toEnglish(2077, 6, 18); $ad->toDateString(); // 2020-10-04 $ad->toFormattedEnglish(); // October 4, 2020
Helpers
$converter->daysInNepaliMonth(2077, 6); // 30 $converter->daysInEnglishMonth(2020, 2); // 29
Formatting
$bs->format(NepaliDateFormat::DateString); // 2077-06-18 $bs->format(NepaliDateFormat::FormattedNepali); // २०७७ असोज १८, आइतवार $ad->format(EnglishDateFormat::DateString); // 2020-10-04 $ad->format(EnglishDateFormat::FormattedEnglish); // October 4, 2020
Laravel 10+ Usage
use Nutandc\NepaliDateConverter\DateConverter; $converter = app(DateConverter::class); $bs = $converter->toNepali(2020, 10, 4);
Supported Range
- AD: 1944 - 2033
- BS: 2000 - 2090
License
MIT