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
NepaliDateinstance set to00:00:00.000on 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()); // 0Date 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());Related
date.endOfDay(): Return end of the day (23:59:59.999).date.startOfMonth(): Return first day of the current month.date.startOfYear(): Return first day of the current year.
Advertisement
date.diff()
Calculate the chronological difference between two NepaliDate instances in specific time units.
date.endOfDay()
Return a new NepaliDate instance set to the final millisecond of the current day.