ernilambar/nepali-date

Nepali (Bikram Sambat) calendar utilities and BS ↔ AD date conversion for PHP.

Maintainers

Package info

github.com/ernilambar/nepali-date

Documentation

pkg:composer/ernilambar/nepali-date

Statistics

Installs: 11 890

Dependents: 1

Suggesters: 0

Stars: 5

Open Issues: 1

1.0.9 2026-04-28 06:09 UTC

This package is auto-updated.

Last update: 2026-04-28 06:10:46 UTC


README

Stable Version Type: Library PHP Version License

Nepali (Bikram Sambat) calendar utilities and BS ↔ AD (Gregorian) date conversion for PHP. This package converts between BS and AD dates and exposes helpers for formatted labels (English or Nepali script).

Requirements

  • PHP 5.6+.
  • Composer for managing PHP dependencies.

Installation

Install the package with Composer (see Packagist):

composer require ernilambar/nepali-date

Autoloading

Require Composer’s autoload once from your project root (where vendor/ lives).

require_once __DIR__ . '/vendor/autoload.php';

Usage

Examples use integers for year, month, and day. The API also accepts numeric strings (e.g. '2077') where values are used numerically.

use Nilambar\NepaliDate\NepaliDate;

$obj = new NepaliDate();

// Convert BS to AD.
$date = $obj->convertBsToAd(2077, 1, 1);

// Convert AD to BS.
$date = $obj->convertAdToBs(2020, 1, 1);

// Date details for a BS date (language: 'en' or 'np' for Devanagari numerals / labels).
$date = $obj->getDetails(2077, 1, 1, 'bs', 'en');
$date = $obj->getDetails(2077, 1, 1, 'bs', 'np');

// Date details for an AD date (converted internally, then formatted like BS).
$date = $obj->getDetails(2020, 1, 1, 'ad', 'en');

getDetails( $year, $month, $day, $type, $language ): $type is 'bs' or 'ad'; $language is optional and defaults to 'en'.

Supported ranges

Conversions rely on a fixed embedded calendar table. In practice:

  • Gregorian (AD): years 1944–2033 are considered by the range checks; only dates that exist in the table can be converted (the first supported pair is 1944-01-01BS 2000-09-17, and the last supported AD day in the current data is 2033-04-13BS 2089-12-30).
  • Bikram Sambat (BS): years 2000–2089 are in range; individual month/day combinations must still exist in the table (invalid or out-of-range inputs typically yield an empty array from conversion methods).

Copyright and License

This project is licensed under the MIT.

2026 © Nilambar Sharma.