logo
Fast AD ↔ BS date conversion utilities

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.

A

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 }
B

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-13
A

AD String to BS

Convert a date string directly into a formatted BS date string.

Input

adStringToBs('2024-04-13')

Output

'2081-01-01'
B

BS String to AD

Convert a formatted BS string into an AD date string.

Input

bsStringToAd('2081-01-01')

Output

'2024-04-13'
F

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'
P

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 }
V

Validate BS Date

Check whether a given BS date exists inside your calendar data.

Input

isValidBSDate({ year: 2081, month: 1, day: 32 })

Output

true / false
N

Nepali 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 More
getAvailableYears()

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)