Convert Nepali dates with clean, simple utilities.
Showcase of common conversion helpers like AD to BS, BS to AD, string conversion, validation, month days, and Nepali number formatting.
adToBs(new Date('2024-04-13'))
// Result
{
year: 2081,
month: 1,
day: 1
}
toNepaliNumber('2081-01-01')
// Result
'२०८१-०१-०१'Conversion Examples
These are the main exported functions you can use in your app, date picker, forms, reports, or documentation examples.
AD to BS
Convert an English calendar date into a Nepali Bikram Sambat date.
Input
adToBs(new Date('2024-04-13'))Output
{ year: 2081, month: 1, day: 1 }BS to AD
Convert a Nepali Bikram Sambat date object into an AD Date object.
Input
bsToAd({ year: 2081, month: 1, day: 1 })Output
2024-04-13AD String to BS
Convert a date string directly into a formatted BS date string.
Input
adStringToBs('2024-04-13')Output
'2081-01-01'BS String to AD
Convert a formatted BS string into an AD date string.
Input
bsStringToAd('2081-01-01')Output
'2024-04-13'Format BS Date
Format a BS date object into a clean YYYY-MM-DD string.
Input
formatBSDate({ year: 2081, month: 1, day: 1 })Output
'2081-01-01'Parse BS Date
Parse a BS date string into a usable object format.
Input
parseBSDate('2081-01-01')Output
{ year: 2081, month: 1, day: 1 }Validate BS Date
Check whether a given BS date exists inside your calendar data.
Input
isValidBSDate({ year: 2081, month: 1, day: 32 })Output
true / falseNepali Numbers
Convert English digits into Nepali unicode numbers.
Input
toNepaliNumber('2081-01-01')Output
'२०८१-०१-०१'Utility helpers for calendar UI
These functions are useful when building date pickers, dropdowns, validation logic, and formatted UI labels.
Learn MoregetAvailableYears()Returns all supported BS years from your calendar data.
getMonthDays(2081, 1)Returns total days in a BS month.
getMonthDays(2081, 12)Useful for validating date picker month/day options.
Example usage
Copy these utilities into your component, form, or date picker and start converting dates directly.
import {
adToBs,
bsToAd,
adStringToBs,
bsStringToAd,
formatBSDate,
parseBSDate,
isValidBSDate,
getAvailableYears,
getMonthDays,
toNepaliNumber,
} from '@/lib/nepali-calendar.utils'
const bsDate = adToBs(new Date('2024-04-13'))
const formatted = formatBSDate(bsDate)
const nepali = toNepaliNumber(formatted)