surazdott / nepali-date
Laravel package to convert English date into Nepali.
Installs: 61
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^8.1
Requires (Dev)
- illuminate/support: ^11.2.0
- orchestra/testbench: ^9.0.0
- phpunit/phpunit: ^11.0.9
README
Introduction
Laravel Nepali Date package is a package integrates seamlessly with Laravel, allowing developers to effortlessly manage date conversions according to the Nepali calendar system.
Installation
You can install the package via composer. Run the following command in your terminal:
composer require surazdott/nepali-date
Basic usages
Laravel will automatically discover this package. Hence, you don't need to add the service provider manually.
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(); // २१ चैत २०८०, बुधवार
Format Specifiers
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 2080
Testing
composer test
Contributing
If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request. Contributions are welcome!
License
This package is open-sourced software licensed under the MIT license.