rakeshrai/laravel-nepali-date-converter

Laravel Nepali Date Converter is a package to convert English (AD) dates to Nepali (BS)

Maintainers

Package info

github.com/myselfrakeshrai/laravel-nepali-date

pkg:composer/rakeshrai/laravel-nepali-date-converter

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-04-19 19:59 UTC

This package is auto-updated.

Last update: 2026-04-19 20:00:04 UTC


README

Author: Rakesh Rai

Convert English (AD) dates to Nepali (BS) in Laravel.

Features

  • AD -> BS converter class
  • bs_date() helper
  • LaravelNepaliDate facade
  • @bs($date) Blade directive
  • Optional middleware to auto-convert AD date text in HTML responses

Installation

composer require rakeshrai/laravel-nepali-date-converter

Development setup

composer install
composer test

Continuous integration

GitHub Actions runs tests automatically on every push and pull request:

  • .github/workflows/tests.yml

Publish config

php artisan vendor:publish --tag=nepali-date-config

Usage

Helper

bs_date('2026-04-20'); // 2083-01-07 (example)
bs_date(now(), 'Y/m/d');

Facade

use LaravelNepaliDate;

LaravelNepaliDate::toString('2026-04-20');
LaravelNepaliDate::from('2026-04-20');
// ['year' => 2083, 'month' => 1, 'day' => 7, 'formatted' => '2083-01-07']

Blade

@bs($user->created_at)

Auto-convert AD date strings in HTML output

In config/nepali-date.php:

'auto_convert_response_dates' => true,

This scans rendered HTML and converts patterns like:

  • 2026-04-20
  • 2026/04/20
  • 2026.04.20

If you do not want global auto registration in web group:

'auto_register_web_middleware' => false,

Then register manually in your app:

// app/Http/Kernel.php
protected $middlewareAliases = [
    // ...
    'auto.bs.date' => \RakeshRai\LaravelNepaliDate\Http\Middleware\AutoConvertAdDatesToBs::class,
];

Supported range

  • Minimum AD: 1943-04-14
  • Maximum depends on packaged BS data table (currently through BS 2099 data)

Notes

  • Auto conversion is text pattern based. For precise control, prefer bs_date() or @bs(...) in Blade.
  • For APIs/JSON, use explicit conversion in transformers/resources.

Demo file

A quick sample integration is available at:

  • examples/laravel-usage.php