UIKit TimePicker如何显示08:00至22:00指定时段?
start:8, end:22 I’ve run into this exact quirk with UIKit v2’s TimePicker before—let’s get your full 08:00 to 22:00 range working properly.
The Root Cause
UIKit v2’s TimePicker treats the end parameter as exclusive: when you set end:22, it stops generating time options at 21:00 instead of including 22:00. That’s why your 22:00 option is missing.
Simple Fix: Adjust the end Value
To include 22:00 in your time range, just set the end parameter to 23 instead. Here’s your updated configuration:
data-uk-timepicker="{start:8, end:23}"
This will make the picker generate every hour from 08:00 all the way through 22:00.
Double-Check Initialization (If Needed)
If the fix above doesn’t take effect right away, confirm that:
- You’ve included the official UIKit v2 JavaScript file in your project (and it loads after your time picker element).
- There are no typos in your
data-uk-timepickerattribute syntax (curly braces, commas, and numbers should all be correctly formatted).
Once you update the end value, refresh your page and you’ll see 22:00 show up in the time picker dropdown.
内容的提问来源于stack exchange,提问作者kupang lie

