import datetime as dt
import panel as pn
pn.extension()
The DatetimeInput
widget allows entering a datetime value as text and parsing it using a pre-defined formatter.
For more information about listening to widget events and laying out widgets refer to the widgets user guide. Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the param user guide. To express interactivity entirely using Javascript without the need for a Python server take a look at the links user guide.
For layout and styling related parameters see the customization user guide.
start
(datetime): Lower boundend
(datetime): Upper boundvalue
(datetime): Parsed datetime valuedisabled
(boolean): Whether the widget is editableformat
(str): Datetime formatting string that determines how the value is formatted and parsed (default='%Y-%m-%d %H:%M:%S'
)name
(str): The title of the widgetThe 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)
":
dt_input = pn.widgets.DatetimeInput(name='Datetime Input', value=dt.datetime(2019, 2, 8))
dt_input
DatetimeInput.value
returns a datetime object and can be accessed and set like other widgets:
dt_input.value
The DateTimeInput
widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:
pn.Row(dt_input.controls(jslink=True), dt_input)