Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.setDate()

Set the day of the month on a NepaliDate instance and recalculate its timestamp.

The setDate method updates the day of the month for the current NepaliDate instance and recalculates its underlying Gregorian timestamp. It validates the new day against the maximum number of days available in the active month.


Import

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

Signature

setDate(day: number): void;

Parameters

ParameterTypeRequiredDescription
daynumberYesDay of the month (1 to 32, validated against current month's length).

Return Value

  • Type: void
  • Mutates the current NepaliDate instance in place.

Exceptions

Error MessageTrigger Condition
Invalid nepali date must be between 1 - <max> in <year> <month>Thrown if day is less than 1 or greater than the maximum days in the current month for this year.

Example

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

const date = new NepaliDate("2081-01-01");
date.setDate(25);

console.log(date.format("YYYY-MM-DD")); // "2081-01-25"

Advertisement

On this page