Skip to content

Laravel package to convert AD to BS that can work with carbon.

License

Notifications You must be signed in to change notification settings

pratiksh404/nepalidate

Repository files navigation

Laravel Nepali Date Converter

Laravel Nepali Date Converter

Latest Version on PackagistStars Downloads StyleCI Build Status Scrutinizer Code Quality CodeFactor License

Laravel package to convert AD to BS that can work with carbon.

Installation

You can install the package via composer:

composer require pratiksh/nepalidate

Usages

By Using Facade.

use Pratiksh\Nepalidate\Facades\NepaliDate;

NepaliDate::create(\Carbon\Carbon::now())->toBS(); // 2078-4-21
NepaliDate::create(\Carbon\Carbon::now())->toFormattedBSDate(); // 21 Shrawan 2078, Thurday
NepaliDate::create(\Carbon\Carbon::now())->toFormattedNepaliDate(); // २१ साउन २०७८, बिहिवार

By Using Helper Function.

use Pratiksh\Nepalidate\Facades\NepaliDate;

toBS(\Carbon\Carbon::now()); // 2078-4-21
toFormattedBSDate(\Carbon\Carbon::now()); // 21 Shrawan 2078, Thurday
toFormattedNepaliDate(\Carbon\Carbon::now()); // २१ साउन २०७८, बिहिवार

Mode Controlled Nepali Date Helper

for this to work publish config file

php artisan vendor:publish --provider="Pratiksh\Nepalidate\Providers\NepalidateServiceProvider"

then in config

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Nepali Date Return Mode
    |--------------------------------------------------------------------------
    | 1 = toBS
    | 2 = toFormattedBSDate
    | 3 = toFormattedBSDate
    |
    */
    'mode' => 1
];
// OUTPUT
// if mode = 1 then output 2078-4-21
// if mode = 2 then output 21 Shrawan 2078, Thurday
// if mode = 3 then output २१ साउन २०७८, बिहिवार
nepalidate(\Carbon\Carbon::now());

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email pratikdai404@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.