Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).

import datetime as dt
import panel as pn


The DatetimeRangeInput widget allows selecting a datetime range using two DatetimeInput widgets, which return a tuple range.

Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.


For details on other options for customizing the component see the layout and styling how-to guides.


  • format (str): Datetime formatting string that determines how the value is formatted and parsed (default='%Y-%m-%d %H:%M:%S')

  • start (datetime): The range’s lower bound

  • end (datetime): The range’s upper bound

  • value (tuple): Tuple of upper and lower bounds of the selected range expressed as datetime types


  • disabled (boolean): Whether the widget is editable

  • name (str): The title of the widget

The datetime parser uses the defined format to validate the input value, if the entered text is not a valid datetime a warning will be shown in the title as “(invalid)”:

datetime_range_input = pn.widgets.DatetimeRangeInput(
    name='Datetime Range Input',
    start=dt.datetime(2017, 1, 1), end=dt.datetime(2019, 1, 1),
    value=(dt.datetime(2017, 1, 1), dt.datetime(2018, 1, 10)),


DatetimeRangeInput.value returns a tuple of datetime values that can be read out and set like other widgets:

(datetime.datetime(2017, 1, 1, 0, 0), datetime.datetime(2018, 1, 10, 0, 0))


The DatetimeRangeInput widget is a composite widget, which requires Python for communication. Therefore the controls only work when connected in a live Python server/kernel:

pn.Row(datetime_range_input.controls(jslink=False), datetime_range_input)

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).