timepicker-ui
4.7.0GitHub
timepicker-ui
Basic Examples / 12h Format

12h Format

Examples using 12-hour clock format with AM/PM

Default 12h Format

#

The 12h format is enabled by default:

const picker = new TimepickerUI(input, {
clock: { type: '12h' } // This is the default
});
picker.create();

Custom AM/PM Labels

#

Customize AM and PM labels for different languages or preferences:

const picker = new TimepickerUI(input, {
clock: { type: '12h' },
labels: {
am: 'AM',
pm: 'PM'
}
});
picker.create();

With Current Time

#

Initialize with current time in 12h format:

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

Disabled Hours (12h)

#

Disable specific hours in 12h format:

const picker = new TimepickerUI(input, {
clock: {
type: '12h',
disabledTime: {
hours: [1, 2, 3, 11, 12]
}
}
});
picker.create();

Time Range Restriction

#

Disable time ranges in 12h format:

const picker = new TimepickerUI(input, {
clock: {
type: '12h',
disabledTime: {
ranges: '10:00 AM - 2:00 PM'
}
}
});
picker.create();

Auto-switch to Minutes

#

Automatically switch to minutes after selecting hour:

const picker = new TimepickerUI(input, {
clock: {
type: '12h',
autoSwitchToMinutes: true
}
});
picker.create();
Esc