Skip to content

Constants

The library exposes month names, weekday names, Nepali numerals, and the complete date mapping table as static properties on NepaliDateLibrary\Helper\Constants.

Import

php
use NepaliDateLibrary\Helper\Constants;

Why a class instead of top-level constants?

NodeJS and Python export these as top-level bindings you import directly (MONTH_EN, NEPALI_DATE_MAP, ...). PHP has no equivalent for named exports outside of classes/functions, so the PHP port groups them as public static properties on Constants instead. The values and indexing are identical across all three ports.


Month Names

Constants::$MONTH_EN

Full English month names.

php
/** @var string[] */
Constants::$MONTH_EN = [
    'Baisakh', 'Jestha', 'Asar', 'Shrawan', 'Bhadra', 'Aswin',
    'Kartik', 'Mangsir', 'Poush', 'Magh', 'Falgun', 'Chaitra',
];

Example:

php
echo Constants::$MONTH_EN[0], PHP_EOL; // 'Baisakh'
echo Constants::$MONTH_EN[9], PHP_EOL; // 'Magh'
echo Constants::$MONTH_EN[11], PHP_EOL; // 'Chaitra'

Constants::$MONTH_SHORT_EN

Short English month names (3 characters).

php
/** @var string[] */
Constants::$MONTH_SHORT_EN = [
    'Bai', 'Jes', 'Asa', 'Shr', 'Bhd', 'Asw',
    'Kar', 'Man', 'Pou', 'Mag', 'Fal', 'Cha',
];

Constants::$MONTH_NP

Full Nepali month names in Devanagari script.

php
/** @var string[] */
Constants::$MONTH_NP = [
    'बैशाख', 'जेठ', 'असार', 'श्रावण', 'भाद्र', 'आश्विन',
    'कार्तिक', 'मंसिर', 'पौष', 'माघ', 'फाल्गुण', 'चैत्र',
];

Example:

php
echo Constants::$MONTH_NP[0], PHP_EOL; // 'बैशाख'
echo Constants::$MONTH_NP[9], PHP_EOL; // 'माघ'

Constants::$MONTH_SHORT_NP

Short Nepali month names.

php
/** @var string[] */
Constants::$MONTH_SHORT_NP = [
    'बै', 'जे', 'अ', 'श्रा', 'भा', 'आ',
    'का', 'मं', 'पौ', 'मा', 'फा', 'चै',
];

Month Reference Table

IndexMONTH_ENMONTH_SHORT_ENMONTH_NPMONTH_SHORT_NP
0BaisakhBaiबैशाखबै
1JesthaJesजेठजे
2AsarAsaअसार
3ShrawanShrश्रावणश्रा
4BhadraBhdभाद्रभा
5AswinAswआश्विन
6KartikKarकार्तिकका
7MangsirManमंसिरमं
8PoushPouपौषपौ
9MaghMagमाघमा
10FalgunFalफाल्गुणफा
11ChaitraChaचैत्रचै

Weekday Names

Constants::$WEEK_EN

Full English day names.

php
/** @var string[] */
Constants::$WEEK_EN = [
    'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday',
];

Example:

php
$dayIndex = (new NepaliDate())->getDay();
echo Constants::$WEEK_EN[$dayIndex], PHP_EOL; // 'Wednesday'

Constants::$WEEK_SHORT_EN

Short English day names (3 characters).

php
/** @var string[] */
Constants::$WEEK_SHORT_EN = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];

Constants::$WEEK_NP

Full Nepali day names in Devanagari script.

php
/** @var string[] */
Constants::$WEEK_NP = [
    'आइतबार', 'सोमबार', 'मंगलबार', 'बुधबार', 'बिहिबार', 'शुक्रबार', 'शनिबार',
];

Constants::$WEEK_SHORT_NP

Short Nepali day names.

php
/** @var string[] */
Constants::$WEEK_SHORT_NP = ['आइत', 'सोम', 'मंगल', 'बुध', 'बिहि', 'शुक्र', 'शनि'];

Weekday Reference Table

IndexWEEK_ENWEEK_SHORT_ENWEEK_NPWEEK_SHORT_NP
0SundaySunआइतबारआइत
1MondayMonसोमबारसोम
2TuesdayTueमंगलबारमंगल
3WednesdayWedबुधबारबुध
4ThursdayThuबिहिबारबिहि
5FridayFriशुक्रबारशुक्र
6SaturdaySatशनिबारशनि

Nepali Numbers

Constants::$NUMBER_NP

Array of Nepali numerals (०-९).

php
/** @var string[] */
Constants::$NUMBER_NP = ['०', '१', '२', '३', '४', '५', '६', '७', '८', '९'];

Example:

php
// Convert an English number to Nepali digits
function toNepaliNumber(int $num): string
{
    $digits = str_split((string) $num);
    return implode('', array_map(fn ($d) => Constants::$NUMBER_NP[(int) $d], $digits));
}

echo toNepaliNumber(2082), PHP_EOL; // '२०८२'
echo toNepaliNumber(15), PHP_EOL;   // '१५'

TIP

The format() method with lowercase tokens automatically uses Nepali numerals:

php
$date = new NepaliDate(2082, 9, 15);
echo $date->format('yyyy-mm-dd'), PHP_EOL; // '२०८२-१०-१५'

Date Map

Constants::$NEPALI_DATE_MAP

Complete mapping of days in each month for years BS 1976-2100.

php
/**
 * @var array<int, array{
 *     year: int,
 *     days: int[],       // Array of 12 month lengths
 *     totalDays: int,    // Total days in the year
 *     daysTillNow: int,  // Cumulative days from the start of the supported range
 * }>
 */
Constants::$NEPALI_DATE_MAP;

totalDays and daysTillNow are computed once by Constants::init(), which runs automatically when the file is loaded — you never need to call it yourself.

Structure:

php
// Example entries
[
    [
        'year' => 2000,
        'days' => [30, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31],
        'totalDays' => 365,
        'daysTillNow' => 8760, // cumulative from BS 1976
    ],
    [
        'year' => 2001,
        'days' => [31, 31, 32, 31, 31, 31, 30, 29, 30, 29, 30, 30],
        'totalDays' => 365,
        'daysTillNow' => 9125,
    ],
    // ... continues to 2100
]

Example Usage:

php
use NepaliDateLibrary\Helper\Constants;

// Get month lengths for a specific year
$mapStartYear = Constants::$NEPALI_DATE_MAP[0]['year'];
$year2082 = Constants::$NEPALI_DATE_MAP[2082 - $mapStartYear];

print_r($year2082['days']);
// [31, 32, 31, 32, 31, 30, 30, 30, 29, 30, 29, 31]

// Days in Magh 2082 (month index 9)
echo $year2082['days'][9], PHP_EOL; // 30

// Total days in 2082
echo $year2082['totalDays'], PHP_EOL; // 366

Month Length Variations

Nepali months have varying lengths (29-32 days) depending on the year:

MonthMin DaysMax DaysTypical
Baisakh303131
Jestha313231-32
Asar313231-32
Shrawan313232
Bhadra313231-32
Aswin303130-31
Kartik293029-30
Mangsir293029-30
Poush293029-30
Magh293029-30
Falgun293029-30
Chaitra303130-31

WARNING

Never hardcode month lengths! Always use daysInMonth() or the date map to get accurate values.


Using Constants for Custom Formatting

php
use NepaliDateLibrary\Helper\Constants;
use NepaliDateLibrary\NepaliDate;

function formatDateCustom(NepaliDate $date, bool $nepali = false): string
{
    $months = $nepali ? Constants::$MONTH_NP : Constants::$MONTH_EN;
    $days = $nepali ? Constants::$WEEK_NP : Constants::$WEEK_EN;

    return sprintf(
        '%s, %s %d, %d',
        $days[$date->getDay()],
        $months[$date->getMonth()],
        $date->getDate(),
        $date->getYear()
    );
}

$date = new NepaliDate(2082, 9, 15);
echo formatDateCustom($date), PHP_EOL;       // 'Wednesday, Magh 15, 2082'
echo formatDateCustom($date, true), PHP_EOL; // 'बुधबार, माघ 15, 2082'

Released under the MIT License.