Dear Community,
I would like to use DatetimePicker and DatetimeRangePicker but I fail to get the time part.
Running this code :
# -*- coding: utf-8 -*-
"""
This module provides a DatetimePicker test.
"""
# bokeh serve --show test_datetime_picker.py
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# Standard library imports
import time
# External imports
from bokeh.layouts import column
from bokeh.models import DatetimePicker
from bokeh.plotting import curdoc
def datetime_picker_handler(attr, old, new):
"""
Handler
"""
print(f"datetime {attr=} changed from {old=} to {new=}")
print(f"datetime {attr=} changed: {type(old)=} {type(new)=}")
start = time.gmtime(new / 1000)
print(f"{start=}")
datetime_picker = DatetimePicker(
title="Select date and time",
value="2026-09-15T17:10:51",
min_date="2026-09-14T09:00:00",
max_date="2026-10-30T18:00:00",
seconds=True,
# width=400,
# date_format='Z',
)
print(f"{time.time()=}")
time.sleep(1.0)
print(f"{time.time()=}")
datetime_picker.on_change("value",datetime_picker_handler)
curdoc().add_root(column(datetime_picker))
I get this trace :
bokeh serve --show test_datetime_picker.py
2026-09-21 11:18:01,083 Starting Bokeh server version 3.10.0 (running on Tornado 6.5.8)
2026-09-21 11:18:01,088 Bokeh app running at: http://localhost:5006/test_datetime_picker
2026-09-21 11:18:01,089 Starting Bokeh server with process id: 19120
time.time()=1789982281.4580224
time.time()=1789982282.4593346
2026-09-21 11:18:02,618 WebSocket connection opened
2026-09-21 11:18:02,619 ServerConnection created
datetime attr='value' changed from old=1789430400000.0 to new=1790035200000.0
datetime attr='value' changed: type(old)=<class 'float'> type(new)=<class 'float'>
start=time.struct_time(tm_year=2026, tm_mon=9, tm_mday=22, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=265, tm_isdst=0)
2026-09-21 11:19:42,640 WebSocket connection closed: code=1001, reason=None
There are several problems :
- the displayed date and time is showing time = 02:00 whatever time is provided in “value”
- seconds are displayed in the calendar but not in the field
- returned time is always 00:00:00
The same goes with the DatetimeRangePicker but in addition only one time can be set.
I have gathered some info :
Python version : 3.13.14 (tags/v3.13.14:fd17997, Jun 10 2026, 13:03:48) [MSC v.1944 64 bit (AMD64)]
IPython version : 9.17.1
Tornado version : 6.5.8
NumPy version : 2.5.2
Bokeh version : 3.10.0
BokehJS static path : C:\Users\s.los\python\Sound2\Bokeh\venv\Lib\site-packages\bokeh\server\static
node.js version : v24.7.0
npm version : 11.5.1
jupyter_bokeh version : (not installed)
Operating system : Windows-11-10.0.26200-SP0
It behaves the same on Firefox and Edge.
Hope it helps.
Thanks in advance for your kind support.
Stéphane