Download the PHP package sghimire/nepali-date-library without Composer
On this page you can find all versions of the php package sghimire/nepali-date-library. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sghimire/nepali-date-library
More information about sghimire/nepali-date-library
Files in sghimire/nepali-date-library
Package nepali-date-library
Short Description A Nepali Date Library for PHP (Bikram Sambat ↔ AD conversion, formatting, and manipulation)
License MIT
Homepage https://nepalidate.sandip-ghimire.com.np
Informations about the package nepali-date-library
NepaliDate Library (PHP)
Overview
The NepaliDate PHP library provides a proper way to work with Nepali (Bikram Sambat) dates.
It allows you to create, manipulate, format, and convert between Nepali Bikram Sambat dates (1976/01/01 - 2100/12/30) and Gregorian dates (1919-04-13 - 2044-04-12). It also supports fiscal years, quarters, and extensive date operations.
This library is a PHP port of the original TypeScript/JavaScript NepaliDate library, with an identical API surface wherever PHP allows it.
📚 Documentation
For detailed guides, API references, and examples, please visit the official Wiki:
👉 nepalidate.sandip-ghimire.com.np
Installation
Requires PHP 7.1 through 8.5.
Quick Start
Format tokens
| Token | Meaning | Example |
|---|---|---|
YYYY / YYY / YY |
English year (4/3/2 digits) | 2080 / 080 / 80 |
yyyy |
Nepali-digit year | २०८० |
M / MM / MMM / MMMM |
English month (1-indexed) | 1 / 01 / Bai / Baisakh |
m / mm / mmm / mmmm |
Nepali month | १ / ०१ / बै / बैशाख |
D / DD |
Day of month | 5 / 05 |
DDD / DDDD |
English weekday | Fri / Friday |
d / dd |
Nepali-digit day of month | ५ / ०५ |
ddd / dddd |
Nepali weekday | शुक्र / शुक्रबार |
Wrap literal text in double quotes to prevent it from being interpreted as a token, e.g. "M"MM outputs M01.
Notes on this port
NepaliDate::isValid()is a static method (matches the JS API exactly); the instance check is namedisValidInstance()since PHP doesn't allow a static and instance method to share one name.- Weekday and time-of-day getters (
getDay(),getHours(),getMinutes(),getSeconds(),getMilliseconds()) andstartOfDay()/endOfDay()are computed in UTC, so results are independent of the host machine's timezone.
Testing
The test suite includes a full-range verification that every supported day (BS 1976-2100) round-trips correctly between BS and AD.