Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.endOfMonth()

Return a new NepaliDate instance set to the final day of the current Bikram Sambat month.

The endOfMonth method returns a new NepaliDate instance positioned on the last valid calendar day of the active month. It automatically checks the calendar map to determine whether the month ends on day 29, 30, 31, or 32, which is useful for monthly reporting and billing cycles.


Import

import { NepaliDate } from "nepali-date-library";

Signature

endOfMonth(): NepaliDate;

Parameters

This method does not take any parameters.


Return Value

  • Type: NepaliDate
  • Returns a new NepaliDate set to the last calendar day of the month at 23:59:59.999. The original instance is not modified.

Examples

Determining Last Day of the Month

import { NepaliDate } from "nepali-date-library";

// 2081 Baisakh (which has 31 days)
const date = new NepaliDate(2081, 0, 10);

const lastDay = date.endOfMonth();
console.log(lastDay.getDate()); // 31
console.log(lastDay.format("YYYY-MM-DD")); // "2081-01-31"
console.log(lastDay.getHours()); // 23
console.log(lastDay.getMinutes()); // 59

Variable Month Ends Across Years

import { NepaliDate } from "nepali-date-library";

// 2080 Chaitra has 30 days
const chaitra2080 = new NepaliDate(2080, 11, 1).endOfMonth();
console.log(chaitra2080.getDate()); // 30

// 2081 Chaitra has 30 days
const chaitra2081 = new NepaliDate(2081, 11, 1).endOfMonth();
console.log(chaitra2081.getDate()); // 30

Advertisement

On this page