timepicker-ui
4.7.0GitHub
timepicker-ui
Features / Current Time

Current Time

Start the picker on the current time, or on a time you choose, with clock.defaultTime.

Simple Current Time

#

Set defaultTime to 'now' to show the current time and write it to the input:

const picker = new TimepickerUI(input, {
clock: { defaultTime: 'now' }
});
picker.create();

Current Time Without Updating the Input

#

With the object form and updateInput: false, the picker opens on the current time and the input stays empty until the user confirms:

const picker = new TimepickerUI(input, {
clock: {
defaultTime: {
time: 'now',
updateInput: false
}
}
});
picker.create();

Clock Type from the Locale

#

Use clock.type: 'auto' to pick 12h or 24h from the browser locale:

const picker = new TimepickerUI(input, {
clock: {
type: 'auto',
defaultTime: 'now'
}
});
picker.create();

Custom Time

#

Set specific time instead of current:

const customTime = new Date();
customTime.setHours(14, 30, 0);
const picker = new TimepickerUI(input, {
clock: {
defaultTime: {
time: customTime,
updateInput: true
}
}
});
picker.create();
Esc