Nepali DateNepali DateBikram Sambat Date Engine
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 NepaliDate set to day 1 of 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()); // 1

Calendar 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.

Advertisement

On this page