Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.startOfDay()

Return a new NepaliDate instance set to the first moment of the current day at midnight.

The startOfDay method returns a new NepaliDate instance with time coordinates set to midnight at 00 hours, 00 minutes, 00 seconds, and 000 milliseconds. This is useful for date normalization and time neutral comparisons.


Import

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

Signature

startOfDay(): NepaliDate;

Parameters

This method does not take any parameters.


Return Value

  • Type: NepaliDate
  • Returns a new cloned NepaliDate instance set to 00:00:00.000 on the same calendar day. The original instance is not modified.

Examples

Normalizing Date to Midnight

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

const date = new NepaliDate();
const start = date.startOfDay();

console.log(start.getHours()); // 0
console.log(start.getMinutes()); // 0
console.log(start.getSeconds()); // 0
console.log(start.getMilliseconds()); // 0

Date Range Queries

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

// Generate midnight boundaries for database filters
const fromDate = new NepaliDate("2081-02-10").startOfDay();
const toDate = new NepaliDate("2081-02-10").endOfDay();

console.log(fromDate.getEnglishDate().toISOString());
console.log(toDate.getEnglishDate().toISOString());

Advertisement

On this page