useDateRangeTimePicker

Hook for date range selection combined with time selection for both start and end dates. Merges the capabilities of useDateRangePicker and time management into a single hook.

Import

import { useDateRangeTimePicker } from "react-date-range-picker-headless";

Usage

import { useState } from "react";
import { useDateRangeTimePicker } from "react-date-range-picker-headless";
function MyDateRangeTimePicker() {
const [range, setRange] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
const picker = useDateRangeTimePicker({
value: range,
onChange: setRange,
time: { precision: "minute", hourFormat: "24", minuteStep: 15 },
});
return (
<div ref={picker.containerRef}>
<button onClick={picker.handleToggle}>
{picker.displayValue || picker.locale.rangeTimePlaceholder}
</button>
{picker.isOpen && (
<div ref={picker.popupRef} onKeyDown={picker.handleKeyDown}>
{/* Dual calendar, presets, time controls for start and end */}
</div>
)}
</div>
);
}

Options

OptionTypeDefaultDescription
value{ start: Date | null; end: Date | null }Required. Current range value.
onChange(value: { start: Date | null; end: Date | null }) => voidRequired. Called when the range changes.
timeTimeConfig{ precision: "minute", hourFormat: "24", minuteStep: 5, secondStep: 1 }Time picker configuration for both start and end times.
maxDaysnumberMaximum days in range.
minDaysnumberMinimum days in range.
presetsDateRangePreset[]Predefined range presets.
allowSingleDateInRangebooleantrueAllow start === end.
minDateDateEarliest selectable date.
maxDateDateLatest selectable date.
localePartial<Locale>DEFAULT_LOCALEOverride locale strings.
initialMonthDateInitial month to display.
sizeDatePickerSizeUI pass-through.
weekStartsOnWeekDay"sunday"First day of the week.
isDateUnavailable(date: Date) => booleanCustom function to disable dates.
displayFormatstringCustom display format.
openbooleanControlled open state.
initialOpenbooleanfalseInitial open state.
onOpenChange(open: boolean) => voidOpen state callback.
requiredbooleanfalsePrevent clearing.
todayDatenew Date()Override today.
onMonthChange(month: Date) => voidMonth change callback.
disablePastbooleanfalseDisable past dates.
disableFuturebooleanfalseDisable future dates.
showOutsideDaysbooleanfalseShow adjacent month days.
highlightDatesDate[]Dates to highlight.
shouldCloseOnSelectbooleanfalseAuto-confirm on preset click only.
numberOfMonthsnumber2Number of calendar months.
captionLayoutCaptionLayout"buttons"Caption layout.
fromYearnumbercurrent year - 100Dropdown start year.
toYearnumbercurrent year + 10Dropdown end year.

Return Values

Date State

NameTypeDescription
isOpenbooleanPopup open state.
tempStartDateDate | nullTemporary start date.
tempEndDateDate | nullTemporary end date.
hoveredDateDate | nullCurrently hovered date.
leftMonthDateLeft calendar month.
rightMonthDateRight calendar month.
localeLocaleResolved locale.

Start Time State

NameTypeDescription
startHournumberStart time hour.
startMinutenumberStart time minute.
startSecondnumberStart time second.
startPeriodTimePeriodStart time AM/PM.
isStartTimePickerOpenbooleanStart time sub-panel open state.

End Time State

NameTypeDescription
endHournumberEnd time hour.
endMinutenumberEnd time minute.
endSecondnumberEnd time second.
endPeriodTimePeriodEnd time AM/PM.
isEndTimePickerOpenbooleanEnd time sub-panel open state.

Date Actions

NameTypeDescription
handleDateClick(date: Date) => voidDay cell click.
handleDateHover(date: Date | null) => voidHover for range preview.
handlePrevMonth() => voidPrevious month.
handleNextMonth() => voidNext month.
handleOpen() => voidOpen popup.
handleClose() => voidClose popup.
handleToggle() => voidToggle popup.
handleConfirm() => voidConfirm and close.
handleCancel() => voidCancel and revert.
handleClear() => voidClear value.
handleGoToToday() => voidNavigate to today.

Start Time Actions

NameTypeDescription
handleStartHourChange(hour: number) => voidUpdate start hour.
handleStartMinuteChange(minute: number) => voidUpdate start minute.
handleStartSecondChange(second: number) => voidUpdate start second.
handleStartPeriodChange(period: TimePeriod) => voidToggle start AM/PM.
handleStartTimePickerOpen() => voidOpen start time sub-panel.
handleStartTimePickerClose() => voidClose start time sub-panel.
handleStartTimePickerConfirm() => voidConfirm start time sub-panel.
handleStartTimePickerCancel() => voidCancel start time sub-panel.

End Time Actions

NameTypeDescription
handleEndHourChange(hour: number) => voidUpdate end hour.
handleEndMinuteChange(minute: number) => voidUpdate end minute.
handleEndSecondChange(second: number) => voidUpdate end second.
handleEndPeriodChange(period: TimePeriod) => voidToggle end AM/PM.
handleEndTimePickerOpen() => voidOpen end time sub-panel.
handleEndTimePickerClose() => voidClose end time sub-panel.
handleEndTimePickerConfirm() => voidConfirm end time sub-panel.
handleEndTimePickerCancel() => voidCancel end time sub-panel.

Computed

NameTypeDescription
leftCalendarCalendarMonthLeft panel calendar data.
rightCalendarCalendarMonthRight panel calendar data.
calendarsCalendarMonth[]All calendar months.
getDayProps(date: Date, referenceMonth?: Date) => DayPropsDay cell props.
displayValuestringFormatted range + time string.
startTimeDisplayValuestringFormatted start time string.
endTimeDisplayValuestringFormatted end time string.
hasValuebooleanWhether a value is confirmed.
canConfirmbooleanWhether confirmation is valid.
containerRefRefObject<HTMLDivElement | null>Container ref.
popupRefRefObject<HTMLDivElement | null>Popup ref.
startTimePickerRefRefObject<HTMLDivElement | null>Start time sub-panel ref.
endTimePickerRefRefObject<HTMLDivElement | null>End time sub-panel ref.
focusedDateDate | nullKeyboard-focused date.
handleKeyDown(e: KeyboardEvent<HTMLElement>) => voidKeyboard handler.
resolvedTimeConfigRequired<TimeConfig>Resolved time config.
presetsDateRangePreset[]Presets passthrough.
handlePresetClick(preset: DateRangePreset) => voidApply a preset.
activePresetIndexnumberMatching preset index.
yearsnumber[]Years for dropdown.
monthsnumber[]Months for dropdown.
handleYearSelect(year: number, calendarIndex?: number) => voidSet year.
handleMonthSelect(month: number, calendarIndex?: number) => voidSet month.

Key Behaviors

Separate Start/End Time Controls

Unlike useDateTimePicker which has a single set of time controls, this hook provides independent hour/minute/second/period state and handlers for both start and end times. Each has its own sub-panel open/close/confirm/cancel flow.

shouldCloseOnSelect

For date-range-time pickers, shouldCloseOnSelect only applies to preset clicks. Date clicks do not auto-confirm because the user still needs to configure the time for both start and end.

Time Configuration

The single time option applies to both start and end time pickers. Both share the same precision, hour format, and step settings.