Optional
value: string | number | DateThis constructor takes year, monthIndex i.e 0-11, and date.
Example:
new Date(2051, 0, 1) // Baisakh 1, 2051
Private
[datePrivate
[dayPrivate
[jsPrivate
[monthPrivate
[yearStatic
languageDefault language for formatting. Set the value to 'np' for default nepali formatting.
Private
[convertPrivate
[convertPrivate
[setPrivate
[setFormat Nepali date string based on format string.
YYYY - 4 digit of year (2077)
YYY - 3 digit of year (077)
YY - 2 digit of year (77)
M - month number (1 - 12)
MM - month number with 0 padding (01 - 12)
MMM - short month name (Bai, Jes, Asa, Shr, etc.)
MMMM - full month name (Baisakh, Jestha, Asar, ...)
D - Day of Month (1, 2, ... 31, 32)
DD - Day of Month with zero padding (01, 02, ...)
d - Week day (0, 1, 2, 3, 4, 5, 6)
dd - Week day in short format (Sun, Mon, ..)
ddd - Week day in long format (Sunday, Monday, ...)
Set language to 'np' for nepali format. The strings can be combined in any way to create desired format.
let a = new NepaliDate(2054,10,10);
a.format('YYYY/MM/DD') // '2054/11/10'
a.format('YYYY MM DD') // '2054 11 10'
a.format('YYYY') // '2054'
a.format('ddd DD, MMMM YYYY') // 'Sunday 10, Falgun 2054'
a.format('To\\day is ddd DD, MMMM YYYY') // 'Today is Sunday 10, Falgun 2054', Note: use '\\' to escape [YMDd]
a.format('DD/MM/YYYY', 'np') //' १०/११/२०५४'
a.format('dd', 'np') // 'आइतबार'
a.format('ddd DD, MMMM YYYY','np') // 'आइतबार १०, फाल्गुण २०५४'
// Set static variable to 'np' for default Nepali language
NepaliDate.language = 'np'
a.format('ddd DD, MMMM YYYY') // 'आइतबार १०, फाल्गुण २०५४'
en | np
Set date in the current date object. It can be positive or negative. Positive values within the month will update the date only and more then month mill increment month and year. Negative value will deduct month and year depending on the value. It is similar to javascript Date API.
Example:
let a = new NepaliDate(2054,10,10);
a.setDate(11); // will make date NepaliDate(2054,10,11);
a.setDate(-1); // will make date NepaliDate(2054,9,29);
a.setDate(45); // will make date NepaliDate(2054,10,15);
positive or negative integer value to set date
Set month in the current date object. It can be positive or negative. Positive values within the month will update the month only and more then month mill increment month and year. Negative value will deduct month and year depending on the value. It is similar to javascript Date API.
Example:
let a = new NepaliDate(2054,10,10);
a.setMonth(1); // will make date NepaliDate(2054,11,10);
a.setMonth(-1); // will make date NepaliDate(2053,11,10);
a.setMonth(12); // will make date NepaliDate(2054,0,10);
Static
fromADStatic
nowStatic
parseGenerated using TypeDoc
String
Provide a valid Nepali date string. The current supported formats are:
Example:
Number
The number value represents the UTC timestamp that will be converted to Nepali date.
Example:
Date
Javascript Date object
Example:
Empty constructor
If no values are provided, the current day date will be converted to Nepali date.