Nepali DateNepali DateBikram Sambat Date Engine
Class

PackagistInstance Properties & Getters

Guide to property encapsulation and public getters available on every NepaliDate instance in PHP.

In PHP the NepaliDate class follows strict object oriented encapsulation principles. Internal state properties are private to protect calendar integrity, while public getter methods provide access to the four digit Bikram Sambat year, zero based month index, day of the month, and underlying Gregorian timestamp.


Public Getters Reference

MethodReturn TypeDescriptionValue Range
$date->getYear()intThe four digit Bikram Sambat year.1976 to 2100
$date->getMonth()intThe zero based Bikram Sambat month index.0 (Baisakh) to 11 (Chaitra)
$date->getDate()intThe day of the month.1 to 32
$date->getEnglishDate()DateTimeImmutableThe equivalent Gregorian date in UTC.Native PHP DateTimeImmutable
$date->getTime()intThe Unix epoch millisecond timestamp.64-bit integer timestamp

Examples

Reading Coordinates via Getters

use NepaliDateLibrary\NepaliDate;

$date = new NepaliDate('2081-07-15');

echo $date->getYear();            // 2081
echo $date->getMonth();           // 6 (Kartik is index 6)
echo $date->getDate();            // 15
echo $date->getEnglishDate()->format('Y-m-d'); // "2024-10-31"

Working with Month Indices

Because $date->getMonth() is zero based, add 1 when outputting conventional month numbers:

$humanMonth = $date->getMonth() + 1; // 7
echo NepaliDate::getMonthName($date->getMonth()); // "Kartik"

Advertisement

On this page