jQuery UI Timepicker

What is this?

This is a jQuery UI time picker plugin build to match with other official jQuery UI widgets like the date picker. Based on the existing date picker, this plugin will integrate nicely with your form and use your selected jQuery UI theme. The plugin is very easy to integrate in your form for you time (hours / minutes) inputs.

Usage:

$('#timepicker').timepicker({
    // Options
    timeSeparator: ':',           // The character to use to separate hours and minutes. (default: ':')
    showLeadingZero: true,        // Define whether or not to show a leading zero for hours < 10. (default: true)
    showMinutesLeadingZero: true, // Define whether or not to show a leading zero for minutes < 10. (default: true)
    showPeriod: false,            // Define whether or not to show AM/PM with selected time. (default: false)
    showPeriodLabels: true,       // Define if the AM/PM labels on the left are displayed. (default: true)
    altField: '#alternate_input', // Define an alternate input to parse selected time to
    defaultTime: '12:34',         // Define a default time to use if displayed inline or input is empty
    zIndex: null,                 // Overwrite the default zIndex used by the time picker
    
    // trigger options
    showOn: 'focus',              // Define when the timepicker is shown.
                                  // 'focus': when the input gets focus, 'button' when the button trigger element is clicked,
                                  // 'both': when the input gets focus and when the button is clicked.
    button: null,                 // jQuery selector that acts as button trigger. ex: '#trigger_button'

    // Localization
    hourText: 'Hour',             // Define the locale text for "Hours"
    minuteText: 'Minute',         // Define the locale text for "Minute"
    amPmText: ['AM', 'PM'],       // Define the locale text for periods

    // Events
    onSelect: onSelectCallback,   // Define a callback function when an hour / minutes is selected.
    onClose: onCloseCallback,     // Define a callback function when the timepicker is closed.
    onHourShow: onHourShow,       // Define a callback to enable / disable certain hours. ex: function onHourShow(hour)
    onMinuteShow: onMinuteShow    // Define a callback to enable / disable certain minutes. ex: function onMinuteShow(hour, minute)
});

Examples :

Default time picker : [Show code]

Time picker with period (AM/PM) in input and without hours leading 0s : [Show code]

Time picker with period (AM/PM) in input and with hours leading 0s : [Show code]

Time picker without period in input and without hours leading 0s : [Show code]

Time picker with labels in another language (Français) : [Show code]

Time picker with disabled hours / minutes. 8:30 PM to 6:30 AM disabled : [Show code]

Define when the time picker is shown with the showOn option and set a trigger element with the button option
[Show code]

Time picker without the AM/PM labels on the left (showPeriodLabels option set to false: [Show code]

onSelect (hours and minutes both trigger event) and onClose events : [Show code]

Inline time picker : Alternate field :

[Show code]

Requirements :

Get the release package here : jquery-ui-timepicker-0.1.3.zip

Releases :

0.1.3 - April 12, 2011
Fixed a bug for when input Id had a dot in it, it was getting double escaped when it should not. (Thanks Zdenek Machac)
0.1.2 - April 11, 2011
So in 0.1.1 I created a bug that made timepicker changes the location hash, well not i'ts fixed. (Thanks Lucas Falk)
0.1.1 - April 6, 2011
Changed the cells click and dblclick binding for faster rendering in IE6/7 (Thanks Blair Parsons)
Fixed a class naming bug created in 0.1.0 (Thanks Morlion Peter)
0.1.0 - March 23, 2011
Fixed some bugs with version 0.0.9
0.0.9 - March 22, 2011
Added zIndex option (Thanks Frank Enderle)
Added showPeriodLabels option (default: true) to show/hide AM/PM labels on the left (thanks Frank Enderle)
Added showOn ['focus'|'button'|'both'] and button options for alternate trigger method
0.0.8 - February 17, 2011
Fixed close event not triggered when switching to another input with time picker (thanks Stuart Gregg)
0.0.7 - February 10, 2011
Added function to set time after initialisation :$('#timepicker').timepicker('setTime',newTime);
Added support for disabled period of time : onHourShow and onMinuteShow (thanks Rene Felgentr�ger)
0.0.6 - January 19, 2011
Replaced some div with tables to : fix some display bugs in IE7, fix inline display and fix my headhake.
Added standard "change" event being triggered on the input when the content changes. (Thanks Rasmus Schultz)
Added support for inline timePicker, attached to div or span.
Added altField that receive the parsed time value when selected time changes.
Added defaultTime value to use when input field is missing (inline) or input value is empty. If defaultTime is missing then current time is used.
0.0.5 - January 18, 2011
Now updating time picker selected value when manually typing in the text field (thanks Rasmus Schultz)
Another step toward inline time picker ?
Fixed : with showPeriod: true and showLeadingZero: true, PM hours did not show leading zeros (thanks Chandler May)
Fixed : with showPeriod: true and showLeadingZero: true, Selecting 12 AM shows as 00 AM in the input field, also parsing 12AM did not work correctly (thanks Rasmus Schultz)
0.0.4 - January 10, 2011
Changed showLeadingZero to affect only hours, added showMinutesLeadingZero for minutes display.
Changed the default value of timeSeparator from 'h' to ':'.
Removed width:100% on tables in the css, caused a bug in some browsers.
0.0.3 - January 8, 2011
Fixed a bug with the widget not displaying with some jQuery UI 1.8.7 css. (Thanks Alexander Fietz)
Fixed a display bug on page load, a small empty div was visible at the bottom of pages. (Thanks Gertjan van Roekel)
Modified the jquery-ui-timepicker.css to make the widget more dynamic to style and sizes changes.
0.0.2 - January 4, 2011
Added showPeriod: period (AM/PM) in input and showLeadingZero: to control display of number < 10. (big thanks Steve Commisso)
0.0.1 - December 2010
First release

To Do :

Bug, ideas or comments : frank@fgelinas.com

--
Francois Gelinas