Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.getTime()

Retrieve the numeric timestamp in milliseconds since the Unix epoch.

The getTime method returns the number of milliseconds elapsed since the Unix epoch of January 1, 1970 UTC. This integer value matches the return value of native JavaScript Date getTime and allows direct numerical comparison between date instances.


Import

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

Signature

getTime(): number;

Parameters

  • None.

Return Value

  • Type: number
  • Description: Integer representing milliseconds since January 1, 1970 UTC.

Examples

Getting Unix Epoch Timestamp

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

const date = new NepaliDate("2081-07-15");
console.log(date.getTime()); // 1730332800000

Direct Mathematical Timestamp Comparison

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

const date1 = new NepaliDate("2081-01-01");
const date2 = new NepaliDate("2081-02-01");

const diffMs = date2.getTime() - date1.getTime();
const diffDays = diffMs / (1000 * 60 * 60 * 24);
console.log(diffDays); // 31

Advertisement

On this page