Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.getEnglishDate()

Retrieve the equivalent Gregorian date as a native JavaScript Date object.

The getEnglishDate method returns the native JavaScript Date object corresponding to the current NepaliDate instance. This allows seamless integration with third party libraries, databases, and standard browser APIs that expect a native Gregorian Date object.


Import

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

Signature

getEnglishDate(): Date;

Parameters

  • None.

Return Value

  • Type: Date
  • Description: A standard JavaScript Date instance calibrated in UTC.

Examples

Converting to Native JavaScript Date

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

const nepaliDate = new NepaliDate("2081-07-15");
const jsDate = nepaliDate.getEnglishDate();

console.log(jsDate instanceof Date); // true
console.log(jsDate.toISOString()); // "2024-10-31T00:00:00.000Z"
console.log(jsDate.getUTCFullYear()); // 2024
console.log(jsDate.getUTCMonth()); // 9 (October, 0-indexed)
console.log(jsDate.getUTCDate()); // 31

Passing to Third-Party Date Utilities

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

const date = new NepaliDate("2081-01-01");
const englishDate = date.getEnglishDate();

// Interoperable with Intl.DateTimeFormat or external libraries
const formatted = new Intl.DateTimeFormat("en-US", {
  dateStyle: "full",
  timeZone: "UTC",
}).format(englishDate);

console.log(formatted); // "Saturday, April 13, 2024"

  • BStoAD(): Standalone helper returning a formatted string instead of a Date object.
  • new NepaliDate(date): Constructing a NepaliDate from a JavaScript Date.
Advertisement

On this page