Overview
Complete documentation and feature guide for the Nepali Date Library in PHP applications.
The Nepali Date Library for PHP provides a modern object oriented toolkit with zero external dependencies for Bikram Sambat calendar operations. It handles bidirectional conversion between Bikram Sambat and Gregorian calendars, date arithmetic, custom string formatting, fiscal year calculations, and calendar grid generation for PHP web applications and enterprise systems.
Installation
Install the package via Composer:
composer require sghimire/nepali-date-libraryQuick Example
<?php
require 'vendor/autoload.php';
use NepaliDateLibrary\NepaliDate;
use function NepaliDateLibrary\ADtoBS;
use function NepaliDateLibrary\BStoAD;
// Current Nepali date
$today = new NepaliDate();
echo $today->format('YYYY-MM-DD');
// Specific Bikram Sambat date (month 0 is Baisakh)
$event = new NepaliDate(2081, 6, 15);
echo $event->format('dddd, MMMM DD, YYYY');
// Standalone date conversion helpers
$bsDate = ADtoBS('2024-11-15');
$adDate = BStoAD('2081-07-30');Feature Matrix
| Feature | Support | Description |
|---|---|---|
| Bikram Sambat Calendar Engine | Yes | Calendar matrix spanning 1976 through 2100 BS, audited and updated annually each Ashwin. |
| Bidirectional AD to BS Conversion | Yes | Standalone conversion functions and full object instances. |
| Date Arithmetic | Yes | Add and subtract days, months, and years with automatic rollover. |
| Fiscal Year Operations | Yes | Official Nepalese fiscal calendar starting on 1 Shrawan. |
| Custom Format Patterns | Yes | Token formatting for year, month, weekday, and Devanagari script. |
| Calendar Grid Builder | Yes | Forty two cell matrix generation for calendar interfaces. |
Package Information
| Specification | Details |
|---|---|
| Composer Package | sghimire/nepali-date-library |
| Repository | GitHub |
| Supported PHP | PHP 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4+ |
| License | MIT License |
Advertisement