Laravel Nepali Date package is a package integrates seamlessly with Laravel, allowing developers to effortlessly manage date conversions according to the Nepali calendar system.
You can install the package via composer. Run the following command in your terminal:
composer require surazdott/nepali-dateLaravel will automatically discover this package. Hence, you don't need to add the service provider manually. It supports Nepali dates up to 2100 BS.
Let's look at a simple example using Facade:
use Carbon\Carbon;
use NepaliDate\Facades\NepaliDate;
NepaliDate::create(Carbon::now())->toBS(); // 2080-12-20
NepaliDate::create(Carbon::now())->toFormattedBSDate(); // 21 Chaitra 2080, Wednesday
NepaliDate::create(Carbon::now())->toFormattedNepaliDate(); // २१ चैत २०८०, बुधवारUsing Carbon Macroable Trait:
$user->created_at->toBS(); // 2080-12-20
$user->created_at->toFormattedNepaliDate(); // २१ चैत २०८०, बुधवारHere are some commonly used format specifiers.
Y- Year in four digits (2080)m- Month in digit (12)F- Month in full name (January/बैशाख)d- Day in digitl- Day in full name (Sunday/आइतबार)
NepaliDate::create(Carbon::now())->toNepaliFormat('Y-m-d'); // २०८०-१२-२१
NepaliDate::create(Carbon::now())->toBSformat('d F Y'); // 21 Chaitra 2080composer testIf you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request. Contributions are welcome!
This package is open-sourced software licensed under the MIT license.
