Skip to content

Date & Time Picker

Single date with an optional same-screen time picker. Click the header to jump by month or year, or type straight into the segmented field — it accepts Nepali and ASCII digits alike.

Tweak the options below and the live preview updates in place; the snippet underneath always matches exactly what you're looking at.

Framework
— pick a value to see the result —
Options
All options
OptionTypeDefaultDescription
mode'BS' | 'AD''BS'Calendar system the picker opens in.
allowModeTogglebooleantrueShow the BS/AD swap button on the input.
value / defaultValueDate | null— (empty)Controlled / initial selected date. Empty until set.
withTimebooleanfalseShow a same-screen time picker: type into the accessible HH:mm spinbutton fields (Arrow keys step, Nepali digits accepted) or scroll the wheel.
timeFormat'12h' | '24h''24h'Clock style when withTime is on.
minuteStepnumber1Increment of the minute spinner.
minTime / maxTime{ hour, minute }Clamp the selectable time of day; out-of-range hours show disabled on the wheel.
disabledTimes(h, m) => booleanDisable specific hours/minutes on the time wheel.
defaultTime{ hour, minute }nowTime used when withTime turns on with no value.
locale'ne' | 'en''ne'Digit and month-name language.
minDate / maxDateDate | 'today' | '+7d'Earliest / latest selectable day (relative tokens allowed).
disabledWeekdaysnumber[][]Grey-out weekdays (0 = Sunday … 6 = Saturday).
disabledDates(date) => booleanReturn true to disable a specific day.
displayFormatstringYYYY-MM-DD[ HH:mm]dayjs-style tokens for the input text.
closeOnSelectbooleantrue unless withTimeClose the popup right after a day is picked.
allowInputbooleantrueMake the field a native-<input type=date>-style segmented editor: focus selects a section, ↑/↓ step it, digits fill with auto-advance, ←/→ move sections, Backspace clears, separators are always shown. Validated live; Enter/blur commits. Accepts Nepali or ASCII digits. Set false to keep the field read-only.
valueFormat'iso' | 'iso-bs' | 'timestamp' | 'date-object' | { calendar, format }'iso'Shape of the machine value sent to the server — AD ISO by default, stable no matter the display calendar/format. Exposed on onChange/events and written to altField/submitName.
submitNamestringInject a hidden <input name> carrying the machine value (and drop the name from the visible input) so the form submits the right data — select2-style.
altFieldstring | HTMLElementWrite the machine value into an existing element/field (CSS selector or node) — jQuery-UI-style altField.
altFormatValueFormatvalueFormatOverride the format used for altField / submitName only.
clearablebooleantrueShow a × button to clear the current value.
appendTostring | HTMLElementdocument.bodyWhere the popup portal is mounted.
opens'left' | 'right' | 'center' | 'auto''auto'Horizontal alignment of the popup relative to the input.
drops'down' | 'up' | 'auto''auto'Whether the popup opens below or above the input.
adapterCalendarAdapterbuilt-inSwap the BS↔AD conversion engine (advanced).
Events & callbacks
NamePayloadFires when
onChangeDateTimeResultA date (and time) was committed.
onChangeMonthYear(year, month)Navigated to a different month/year.
onOpen()Fires when the popup is shown.
onClose()Fires when the popup is hidden.
select.nepaliDatePickerCustomEvent<DateTimeResult>Bubbling DOM event dispatched on the input.
import { mountDateTimePicker } from 'nepali-datepicker-pro';
import 'nepali-datepicker-pro/style.css';

mountDateTimePicker(document.querySelector('#picker'), {});
Real-world example — Appointment booking form

BS-mode date + time, no past dates, submits a clean AD ISO string to the server under a plain <form> field name.

import { mountDateTimePicker } from 'nepali-datepicker-pro';
import 'nepali-datepicker-pro/style.css';

mountDateTimePicker(document.querySelector('#picker'), {
  withTime: true,
  minDate: 'today',
  valueFormat: 'iso',
  submitName: 'appointment_date'
});

Notes

  • Time is not a second popup. With withTime: true the clock sits under the calendar, as accessible HH:mm spinbuttons — Arrow keys step them, the scroll wheel works, and Nepali digits are accepted.
  • closeOnSelect defaults to true unless withTime is on, so a date-and-time picker stays open long enough to set the time.
  • Constraints accept relative tokens. minDate: 'today', maxDate: '+1m' and friends are resolved at open time, not at mount time.

See also

Released under the MIT License.