jQuery UI Datepicker with hour and minute

Adding a Timepicker to jQuery UI Datepicker

The timepicker addon adds a timepicker to jQuery UI Datepicker, thus the datepicker (jQueryUI) is required for using any of these. In addition all datepicker options are still available through the timepicker addon.

Back to Blog

Download

Download Timepicker Addon

Download Timepicker Addon Minified

There is a small bit of required CSS:

/* css for timepicker */
#ui-timepicker-div dl{ text-align: left; }
#ui-timepicker-div dl dt{ height: 25px; }
#ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }

Donation

Has this Timepicker Addon been helpful to you?

Some Examples

Add a simple timepicker to jQuery UI's datepicker

$('#example1').datetimepicker();

Show time in AM/PM 12 hour format

$('#example2').datetimepicker({
	ampm: true
});

Show only the time picker without date picker

$('#example3').timepicker();

Change the format (default is "hh:mm tt")

h
Hour with no leading 0
hh
Hour with leading 0
m
Minute with no leading 0
mm
Minute with no leading 0
s
Second with no leading 0
ss
Second with no leading 0
t
a or p for AM/PM
tt
A or P for AM/PM
T
am or pm for AM/PM
TT
AM or PM for AM/PM
$('#example4').datetimepicker({
	timeFormat: 'h-m'
});

Show Seconds, Minutes, or Hours

showHour
Show the hour, default=true
showMinute
Show the minute, default=true
showSecond
Show the second, default=false
$('#example5').datetimepicker({
	showSecond: true,
	timeFormat: 'hh:mm:ss'
});

Hours, Minutes, Seconds in steps

stepHour
hour steps, default=1
stepMinute
minute steps, default=1
stepSecond
second steps, default=1
$('#example6').datetimepicker({
	showSecond: true,
	timeFormat: 'hh:mm:ss',
	stepHour: 2,
	stepMinute: 10,
	stepSecond: 10
});

Default Hours, Minutes, Seconds

hour
default=0
minute
default=0
second
default=0
$('#example7').datetimepicker({
	hour: 13,
	minute: 15
});

Version

Version 0.5

Last updated on 6/16/2010

jQuery Timepicker Addon is currently available for use in all personal or commercial projects under both MIT and GPL licenses. This means that you can choose the license that best suits your project, and use it accordingly.

GPL License

MIT License

你可能感兴趣的:(jquery,UI,Date,css,2010)