In this article, we will learn how to add a time picker to the jQueryUI Datepicker using the jQuery Timepicker-Addon image plugin.
Note: Please download the jQuery Timepicker plugin in the working folder and include the required files in the head section of your HTML code.
<link href=”http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css” rel=”stylesheet” type=”text/css”/>
<link href=”jquery-ui-timepicker-addon.css” rel=”stylesheet” type=”text/css”/>
<script src=”http://code.jquery.com/jquery-1.11.1.min.js”></script> <script src=”http://code.jquery.com/ui/1.11.0/jquery-ui.min.js”></script> <script src=”jquery-ui-timepicker-addon.js”></script>
Example 1: The following example demonstrates the instantiation of the jQuery datetimepicker() method of the plugin.
html
<!DOCTYPE html>
<html lang="en"
xmlns=
"http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8" />
<title>Adding a Timepicker to
jQuery UI Datepicker</title>
<style type="text/css">
body {
margin: 0;
padding: 20px;
border: 0;
background-color: #e9e9e9;
border-top: solid 10px #7ba9b2;
font: Arial, sans-serif;
}
.wrapper {
width: 800px;
border: solid 1px #eeeeee;
background-color: #ffffff;
padding: 20px;
margin: 0 auto;
}
</style>
<link rel="stylesheet"
media="all"
type="text/css"
href=
"http://code.jquery.com/ui/1.11.0/themes/
smoothness/jquery-ui.css" />
<link rel="stylesheet"
media="all"
type="text/css"
href=
"jquery-ui-timepicker-addon.css" />
</head>
<body>
<div class="wrapper">
<h2>Adding a Timepicker to
jQuery UI Datepicker</h2>
<div class="container">
<p>Add a simple jQuery
UI datetimepicker</p>
<div>
<input type="text"
name="dateTimePicker"
id="dateTimePicker"
value="" />
</div>
</div>
</div>
<script type="text/javascript"
src=
"http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script type="text/javascript"
src=
"http://code.jquery.com/ui/1.11.0/jquery-ui.min.js">
</script>
<script type="text/javascript"
src=
"jquery-ui-timepicker-addon.js">
</script>
<script type="text/javascript">
// Initialization of datetimepicker
$(function () {
$("#dateTimePicker").datetimepicker();
});
</script>
</body>
</html>
Output:

Adding a Timepicker to jQuery UI Datepicker: In the above HTML code, we can add following settings for "timeFormat", "timezonelist" and for localization. There are many more options that can be used by the programmer depending on the need.
javascript
$(function () {
$('#timePicker').datetimepicker({
timeFormat: "hh:mm tt", //timezone format
timezoneList: [
{ value: -300, label: 'Eastern' },
{ value: -360, label: 'Central' },
{ value: -420, label: 'Mountain' },
{ value: -480, label: 'Pacific' }
]
});
$('#timePicker').timepicker(
//$.timepicker.regional["localization code"]
$.timepicker.regional['en']//English
);
});
Example 2: The following example demonstrates the slider feature with step time intervals for an hour, minute, and seconds time. Please refer to the output for a better understanding. Once the slider is moved, it jumps in time intervals mentioned in the options settings for the time as shown below.
Note: Please don't forget to include the following libraries in your HTML code for the slider feature.
<script src=”i18n/jquery-ui-timepicker-addon-i18n.min.js”></script> <script src=”jquery-ui-sliderAccess.js”></script>
html
<!DOCTYPE html>
<html lang="en"
xmlns=
"http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8" />
<title>Adding a Timepicker to
jQuery UI Datepicker</title>
<style type="text/css">
body {
margin: 0;
padding: 20px;
border: 0;
background-color: #e9e9e9;
border-top: solid 10px #7ba9b2;
font: Arial, sans-serif;
}
.wrapper {
width: 800px;
border: solid 1px #eeeeee;
background-color: #ffffff;
padding: 20px;
margin: 0 auto;
}
</style>
<link rel="stylesheet"
media="all"
type="text/css"
href=
"http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet"
media="all"
type="text/css"
href=
"jquery-ui-timepicker-addon.css" />
</head>
<body>
<div class="wrapper">
<h2>Adding a step interval
timepicker to jQuery UI Datepicker</h2>
<div class="container">
<p>Adding slider with step
intervals for hour, minute and seconds</p>
<div>
<input type="text"
name="datePicker"
id="datePickerID" value="" />
</div>
</div>
</div>
<script type="text/javascript"
src=
"http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script type="text/javascript"
src=
"http://code.jquery.com/ui/1.11.0/jquery-ui.min.js">
</script>
<script type="text/javascript"
src=
"jquery-ui-timepicker-addon.js">
</script>
<script type="text/javascript"
src=
"i18n/jquery-ui-timepicker-addon-i18n.min.js">
</script>
<script type="text/javascript"
src=
"jquery-ui-sliderAccess.js">
</script>
<script type="text/javascript">
$(function () {
$("#datePickerID").datetimepicker();
$("#datePickerID").timepicker({
hourGrid: 4,
minuteGrid: 10,
timeFormat: "hh:mm tt",
addSliderAccess: true,
sliderAccessArgs: { touchonly: true },
stepHour: 2,
// hour interval step
stepMinute: 10,
// minute interval step
stepSecond: 10,
// second interval step
});
});
</script>
</body>
</html>
Output:
Example 3: The following example demonstrates adding a dropdown selector for the datetimepicker().
html
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8" />
<title>Adding a Timepicker to
jQuery UI Datepicker</title>
<style type="text/css">
body {
margin: 0;
padding: 20px;
border: 0;
background-color: #e9e9e9;
border-top: solid 10px #7ba9b2;
font: Arial, sans-serif;
}
.wrapper {
width: 800px;
border: solid 1px #eeeeee;
background-color: #ffffff;
padding: 20px;
margin: 0 auto;
}
</style>
<link
rel="stylesheet"
media="all"
type="text/css"
href="http://code.jquery.com/ui/1.11.0/themes/
smoothness/jquery-ui.css"
/>
<link rel="stylesheet"
media="all"
type="text/css"
href="jquery-ui-timepicker-addon.css" />
</head>
<body>
<div class="wrapper">
<h2>Adding a Timepicker to
jQuery UI Datepicker</h2>
<div class="container">
<p>Use of dropdowns in datetime picker</p>
<div>
<input type="text"
name="datePicker"
id="datePickerID"
value="" />
</div>
</div>
</div>
<script type="text/javascript"
src=
"http://code.jquery.com/jquery-1.11.1.min.js">
</script>
<script type="text/javascript"
src=
"http://code.jquery.com/ui/1.11.0/jquery-ui.min.js">
</script>
<script type="text/javascript"
src="jquery-ui-timepicker-addon.js">
</script>
<script type="text/javascript">
$(function () {
$("#datePickerID").datetimepicker({
controlType: "select",
oneLine: true,
timeInput: true,
timeFormat: "hh:mm tt",
});
});
</script>
</body>
</html>
Output:
Similar Reads
jQuery Page Piling Plugin jQuery pagePiling.js plug-in is a rich feature available for programmers for piling more than one layout section, one over the other, and accessing each page by URL or mouse scrolling or side bullets navigation. This feature provides all type of smooth vertical, horizontal, and side navigations to t
5 min read
jQuery | Flickerplate Plugin jQuery provides Flickerplate plugin that helps our programmers to create sliders for websites that can cycle through a list of background images along with dot navigation feature and animated arrows. The plugin consists of many more libraries that are responsible for touch detections and events such
5 min read
jQuery Multiscroll Plugin jQuery provides multiscroll.js plugin which helps programmers to create split web pages along with divided multiple vertical scrolling panels.Note: Please download the jQuery multiscroll plugin to your working folder and include the required files in the head section of your code as shown below. Dow
3 min read
jQuery RowGrid Plugin jQuery provides a very simple, user-friendly and responsive rowGrid plugin that helps programmers to display images in a straight row. It is very lightweighted and supports infinite scrolling feature. Real examples of rowGrid are Google+ images or Google image search that appears in a straight row g
4 min read
jQuery Alertify Plugin jQuery framework provides alertify.js plugin that provides pre-designed customizable notification system along with interactive browser dialogs. This extensible and themeable plugin is very useful for developers providing an optimized version of alert messages with stacking up to feature. This small
5 min read
jQuery Image ProgressBars Plugin In this article, we will learn how to implement image ProgressBar feature using the jQuery Image ProgressBar plugin. Note: Please download the jQuery Image ProgressBar plugin in the working folder and include the required files in the head section of your HTML code. <link href=âprogressbar.cssâ r
2 min read
jQuery DrawSVG Plugin SVG or Scalar Vector Graphics is Extended Markup Language-based graphics supporting 2 dimensional animations of images enhancing interactiveness. The specifications of SVG are open standards by World Wide Web Consortium defined in XML text files. These files can be changed or created with any drawin
4 min read
jQuery Tagsort Plugin jQuery provides Tagsort plugin that is used for displaying tags or filter elements based on different tags in a DOM. The plugin takes data-attributes of HTML page structure and dynamically creates user-friendly tags used for filtering elements. The filtration of elements are done in many ways that a
9 min read
jQuery Logos Distort Plugin The jQuery provides LogosDistort plugin which helps in creating or animating a parallax environment for 3D scenes in the user browser. It uses full-page matrix3D perspective logos distortions for transforming base on mouse movement. You have to download the required files in the working folder so th
4 min read
jQuery Filer Plugin jQuery provides a quick jQuery Filer uploader plugin for easy implementation of uploading the files. It provides features like instant uploading of files, file append, file removal, multiple selections, drag and drop support along with other file validations.Download the required files to include it
2 min read