Methods
date.getMonth()
Retrieve the zero based Bikram Sambat month index from zero for Baisakh to eleven for Chaitra.
The getMonth method returns the month of the year as an integer between 0 and 11 for the current NepaliDate instance. The library adheres to the JavaScript zero based indexing standard where 0 represents Baisakh, 1 represents Jestha, and 11 represents Chaitra.
Import
import { NepaliDate } from "nepali-date-library";Signature
getMonth(): number;Parameters
- None.
Return Value
- Type:
number - Range:
0to11
| Index | Month (English) | Month (Devanagari) |
|---|---|---|
0 | Baisakh | बैशाख |
1 | Jestha | जेठ |
2 | Ashadh / Asar | असार |
3 | Shrawan | श्रावण |
4 | Bhadra | भाद्र |
5 | Ashwin / Aswin | आश्विन |
6 | Kartik | कार्तिक |
7 | Mangsir | मंसिर |
8 | Poush | पौष |
9 | Magh | माघ |
10 | Falgun | फाल्गुण |
11 | Chaitra | चैत्र |
Example
import { NepaliDate } from "nepali-date-library";
// 2081 Kartik 15
const date = new NepaliDate("2081-07-15");
console.log(date.getMonth()); // 6 (0-indexed)
console.log(date.getMonth() + 1); // 7 (1-indexed for display)Related
date.setMonth(): Mutate the month component.NepaliDate.getMonthName(): Get the localized string name for a month index.
Advertisement
date.getYear()
Retrieve the four digit Bikram Sambat year number from a NepaliDate instance.
date.getDate()
Retrieve the numeric day of the month from a NepaliDate instance.