PHP code example of ashbin / nepali-date

1. Go to this page and download the library: Download ashbin/nepali-date library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ashbin / nepali-date example snippets


$englishDate = nep_to_eng_date('2083-04-25');

$nepaliDate = eng_to_nep_date('2026-08-10');



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use NepDate;

class EventController extends Controller
{
    public function store(Request $request)
    {
        // Convert BS input to AD for database storage
        $englishDate = NepDate::toEng(
            $request->input('nepali_date')
        );

        // Convert AD from database back to BS for API response
        $nepaliDate = NepDate::toNep(
            now()->format('Y-m-d')
        );

        return response()->json([
            'ad_date' => $englishDate,
            'bs_date' => $nepaliDate,
        ]);
    }
}

$englishDate = NepDate::toEng('2083-04-25');

$nepaliDate = NepDate::toNep('2026-08-10');

nep_to_eng_date('2083-04-25');

eng_to_nep_date('2026-08-10');
bash
php artisan migrate