View On



momentnp is a node module that provides various utilities for handling dates, including formatting dates, calculating the time difference from the current time, and converting dates to Nepali formats.


Simply paste the following code into the terminal to install momentnp:

npm install momentnp


yarn add momentnp


To use momentnp, create an instance of the function with a date string or a Date object. If no valid date is provided, it will use the current date.

const myDate = momentnp("2023-06-01");


The fromNow method calculates the difference from the provided date to the current date and returns the difference in Nepali format.

myDate.fromNow(); // Returns the difference in Nepali, e.g., 'केहि क्षण पहिले'


The format method formats the date into different specified formats. Available formats are:

myDate.format("dmy-"); // Returns '2023-06-01'
myDate.format("fullnp"); // Returns full Nepali date with time


The inBS method converts the date to the Bikram Sambat (BS) calendar and returns it in the specified format.

myDate.inBS("YYMMDD"); // Returns BS date in YYYY-MM-DD format
myDate.inBS("ddmmyyfull"); // Returns full Nepali formatted BS date


The isPast method checks if the provided date is in the past.

myDate.isPast(); // Returns true if the date is in the past, otherwise false

Date Formatting Reference

dmy-2023-06-12Date format with hyphens (e.g., YYYY-MM-DD)
dmyt-2023-06-12 14:30:45Date format with hyphens and time (e.g., YYYY-MM-DD HH:MM:SS)
dmy/2023/06/12Date format with slashes (e.g., YYYY/MM/DD)
dmyt/2023/06/12 14:30:45Date format with slashes and time (e.g., YYYY/MM/DD HH:MM:SS)
DDMMYY12 June, 2023Date format with day, month, year (e.g., DD Month, YYYY)
DDDDMMYYMonday, 12 June 2023Date format with day, day of the month, month, year (e.g., Day, DD Month YYYY)
ddDDMMYYMon, 12 Jun 2023Date format with abbreviated day, day of the month, abbreviated month, year (e.g., Day, DD Mon YYYY)
DDDDMMYYnpसोमबार, १२ जेठ २०७९Date format with Nepali day, Nepali day of the month, Nepali month, Nepali year (e.g., Nepali Day, DD Nepali Month YYYY)
DDMMYYnp१२ जेठ, २०७९Date format with Nepali day of the month, Nepali month, Nepali year (e.g., DD Nepali Month, YYYY)
YYMMDDDDnp१२ जेठ २०७९, सोमबारDate format with Nepali day of the month, Nepali month, Nepali year, Nepali day (e.g., DD Nepali Month YYYY, Nepali Day)
dmytnp-२०७९-०६-१२ १४:३०:४५Date format with Nepali digits, hyphens, and time (e.g., YYYY-MM-DD HH:MM:SS)
dmynp-२०७९-०६-१२Date format with Nepali digits and hyphens (e.g., YYYY-MM-DD)
dmynp/२०७९/०६/१२Date format with Nepali digits and slashes (e.g., YYYY/MM/DD)
dmytnp/२०७९/०६/१२ १४:३०:४५Date format with Nepali digits, slashes, and time (e.g., YYYY/MM/DD HH:MM:SS)
fullnpसन् २०७९, ६ महिना १२ गते, १४ बजेर ३० मिनेट ४५ सेकेन्डFull Nepali date format (e.g., सन् Nepali Year, Nepali Month, Nepali Day गते, Nepali Hour बजेर Nepali Minute मिनेट Nepali Second सेकेन्ड)


const dateExample = momentnp("2023-05-21");
console.log(dateExample.fromNow()); // Outputs time difference in Nepali
console.log(dateExample.format("dmy-")); // Outputs '2023-05-21'
console.log(dateExample.format("fullnp")); // Outputs full Nepali formatted date and time
console.log(dateExample.inBS("YYMMDD")); // Outputs BS date in YYYY-MM-DD format
console.log(dateExample.isPast()); // Outputs true or false based on whether the date is in the past