aka beer!

jQuery UI Timepicker (By François Gélinas)

What is this?

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

Licensed under the same license as jQuery : MIT and GPL licenses

[Show code]

[Show code]

See the internationalisation page for more information and details. [Show code]

[Show code]

[Show code]

[Show code]

[Show code]

[Show code]

, [Show code]
[Show code]

[Show code]

[Show code]

Inline time picker :

[Show code]

Two timepickers to select chronological time range, the first timepicker is restricted to before the time selected in the second timepicker, and vice versa. Updated code to use the new minTime and maxTime options
[Show code]

Example of using the new minTime and maxTime options

[Show code]

Example to disable and re-enable a timepicker.

[Show code]

Set the timepicker date with a Date object and get the selected time as a Date object

Also, note that in the returned date object, the time is correct but the yeat/month/day part of the date is wrong, you have to extract the time of the object.
[Show code]


    // 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)
    periodSeparator: ' ',         // The character to use to separate the time from the time period.
    altField: '#alternate_input', // Define an alternate input to parse selected time to
    defaultTime: '12:34',         // Used as default time when input field is empty or for inline timePicker
                                  // (set to 'now' for the current time, '' for no highlighted time,
                                     default value: now)

    // 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

    // Position
    myPosition: 'left top',       // Corner of the dialog to position, used with the jQuery UI Position utility if present.
    atPosition: 'left bottom',    // Corner of the input to position

    // Events
    beforeShow: beforeShowCallback, // Callback function executed before the timepicker is rendered and displayed.
    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)

    // custom hours and minutes
    hours: {
        starts: 0,                // First displayed hour
        ends: 23                  // Last displayed hour
    minutes: {
        starts: 0,                // First displayed minute
        ends: 55,                 // Last displayed minute
        interval: 5,              // Interval of displayed minutes
        manual: []                // Optional extra entries for minutes
    rows: 4,                      // Number of rows for the input tables, minimum 2, makes more sense if you use multiple of 2
    showHours: true,              // Define if the hours section is displayed or not. Set to false to get a minute only dialog
    showMinutes: true,            // Define if the minutes section is displayed or not. Set to false to get an hour only dialog

    // Min and Max time
    minTime: {                    // Set the minimum time selectable by the user, disable hours and minutes
        hour: minHour,            // previous to min time
        minute: minMinute
    maxTime: {                    // Set the minimum time selectable by the user, disable hours and minutes
        hour: maxHour,            // after max time
        minute: maxMinute

    // buttons
    showCloseButton: false,       // shows an OK button to confirm the edit
    closeButtonText: 'Done',      // Text for the confirmation button (ok button)
    showNowButton: false,         // Shows the 'now' button
    nowButtonText: 'Now',         // Text for the now button
    showDeselectButton: false,    // Shows the deselect time button
    deselectButtonText: 'Deselect' // Text for the deselect button


Releases :

0.3.3 - 23 October 2013
Better zIndex detection - Thanks Mark Larter ref #62
Added Hungarian localisation - Thanks Bálint Dávid Tarcsa.
Added the button self if showOn is "button" or "both" and the button element is not explicitely set. Thanks Kevin Reintjes ref #75
Fixed rounding time using not 5 minutes but using minutes from interval. Thanks Jan Dvořák ref #73
Added Option for adding manual entries in minutes display. Thanks Mischa Gorinskat ref #71
Added support for minTime and maxTime options. Thanks @phazei ref #76
0.3.2 - 25 January 2013
Updated to jQuery 1.9.0 and UI 1.10.0. Removed deprecated IE6 hacks.
Added support for Date object with the setTime and getTimeAsDate function - thanks AAverin.
Removed an extra </tr>, thanks FishB8.
Fixed an error that occurs on some showAnim effects like 'blind'.
Fixed a problem when wither hours or minutes was required and missing, the parsed time was not formatted correctly.
Fixed a problem when available hours are all AM or all PM only and they would not show in the grid, thanks @malerbabomba
0.3.1 - 19 July 2012
Added the "destroy" method.
Fixed a bug in the deselect function, thanks Kazu.
Allow for hours and minutes outside normal time range (0-23, 0-59) for more flexibility.
Fixed a bug with the onClose callback that could generate an infinite loop.
Added Croatian/Bosnian translation, thanks Rene Brakus.
Added Portuguese/Brazilan tranlsation, thanks Daniel Almeida.
Added Spanish tranlsation, thanks Jandro González.
Release 0.3.0 - 27 March 2012
Fixed a zIndex problem in jQuery Dialog when the user clicked on the input while the timepicker was still visible.
Added Czech translation, thanks David Spohr
Added Swedish translation, thanks Björn Westlin
Added Dutch translation, thanks Lowie Hulzinga
Prevent showing the timepicker dialog with the button when disabled(Thanks ruhley. ref #38)
Add ui-state-disabled class to button trigger when disabled.
Fixed onClose function on first time passes the hours variable as string (Thanks Zanisimo, ref #39)
Added refresh method. ex: $('selector').timepicker('refresh');
Release 0.2.9 - November 13, 2011
Fixed the zIndex problem and removed the zIndex option (Thanks everyone who reported the problem)
Fix a bug where repeatedly clicking on hour cells made the timepicker very slow.
Added Italian translation, thanks to Serge Margarita.
Release 0.2.8 - October 28, 2011
Updated defaultTime to allow for Date object (github issue #26)
Fixed the now and deselect buttons in IE
Release 0.2.7 - October 19, 2011
Added option to omit minutes in parsed time when user select 0 for minutes. (Thanks tribalvibes, Github issue #23)
Added support for internationalisation (fr, de and ja, Thanks Bernd Plagge).
Added an internationalisation page
0.2.6 - October 12, 2011
Fixed a bug when input ID have more then one special char. (Thanks Jacqueline Krijnen)
Fixed a bug when parsing hours only or minutes only time. (Thanks protron, github issue #20)
Added 'Now', 'Deselect' and 'Close' buttons. (Thanks Christian Grobmeier for the close button code, github issue #22)
0.2.5 - September 13, 2011
Added support for disable and enable. (Suggested by danielrex, github issue #17)
Added an example for 2 timepicker to behave as a period selector (start time and end time). (Thanks Bill Pellowe)
Renamed the stylesheet to jquery.ui.timepicker.css to be more consistent with jQuery UI file name convention.
0.2.4 - August 5, 2011
Fixed the hand cursor in the css file. (Thanks Mike Neumegen)
Added position option to use with the jquery ui position utility.
Added option to display only hours or only minutes.
0.2.3 - July 11, 2011
Fix github issue #3 : Bug when hours or minutes choices does not divide by number of rows (thanks wukimus).
Changed default behavior of the defaultTime option, if set to '' and input is empty, there will be no highlighted time in the popup (Thanks Rasmus Schultz)
Fix github issue #4 : Error when generating empty minute cell. (Thanks 123Haynes)
Fix github issue #5 : Add functionality for "getTime" option. (Thanks edanuff)
Added the periodSeparator option. (thanks jrchamp)
Fixed "getTime" for inline timepickers. (thanks Mike Neumegen)
Added "getHour" and "getMinute" to get individual values.
New page interface, about time :)
0.2.2 - June 16, 2011
Fixed a "console.log" line that I forgot to remove before release 0.2.1. (Thanks Derek Lavine)
0.2.1 - June 8, 2011
Timepicker does not give the focus back to the input any more after time selection. This is similar to the datepicker behaviour and is more natural to the user because it shows the dialog again when the user click on the input again, as expected.
Added options to customize the hours and minutes ranges and interval for more customization.
0.2 - May 28, 2011
In the last release, I messed up versions and lost some changes so I'm fixing all this up with release 0.2
0.1.2 - May 26, 2011
Fixed a bug with inline timepickers that would append a #timepickr hashtag when selecting hours and minutes.
Fixed z-index problem with IE6 (Thanks Graham Bentley)
Added selection of highlighted text when enter is pressed on the input field (Thanks Glen Chiacchieri)
Adjusted some focus problems, now the input gets the focus back when the used click on hours / minutes.
0.1.something aka the lost release - around April 11
Fixed a bug for when input Id had a dot in it, it was getting double escaped when it should not. (Thanks Zdenek Machac)
So in 0.1.1 I created a bug that made timepicker changes the location hash, well now it's 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

Download Timepicker

Current version : 0.3.3 - released 23 October 2013

Get it on github

Download from here (.zip)

I put a lot of time and effort in this project. If you like it, buy me a beer please donate

Instruction for legacy jQuery integration (jQuery 1.2.6 and jQuery UI 1.6)

  • Get the legacy package here , built with jQuery Timepicker 0.2.4 but should work with newer versions
  • Make sure to include jquery-1.2.6.js, jquery.fix.for.1.2.6.js and jquery.ui.1.6.all.js
  • See the working example in index.html in the "legacy_1.2.6" folder.
  • Support for previous versions of jquery is limited.