Methods
date.startOfMonth()
Return a new NepaliDate instance set to the first day of the current Bikram Sambat month.
The startOfMonth method returns a new NepaliDate instance positioned on day 1 of the active Bikram Sambat month with time set to midnight. It is commonly used for monthly calendar views, statements, and aggregation buckets.
Import
import { NepaliDate } from "nepali-date-library";Signature
startOfMonth(): NepaliDate;Parameters
This method does not take any parameters.
Return Value
- Type:
NepaliDate - Returns a new
NepaliDateset to day1of the current year and month. The original instance is not modified.
Examples
Getting the First Day of the Month
import { NepaliDate } from "nepali-date-library";
// 2081 Baisakh 25
const date = new NepaliDate(2081, 0, 25);
const start = date.startOfMonth();
console.log(start.format("YYYY-MM-DD")); // "2081-01-01"
console.log(start.getDate()); // 1Calendar Header Computation
import { NepaliDate } from "nepali-date-library";
const today = new NepaliDate();
const firstDay = today.startOfMonth();
// Find weekday that the month begins on
console.log(firstDay.getDay()); // 0 = Sunday, 1 = Monday, etc.Related
date.endOfMonth(): Return the last day of the current month.date.startOfYear(): Return the first day of the current year.date.daysInMonth(): Return total days in the month.
Advertisement
date.endOfWeek()
Return a new NepaliDate instance set to the final day of the current week on Saturday.
date.endOfMonth()
Return a new NepaliDate instance set to the final day of the current Bikram Sambat month.