"time range picker"
Bootstrap 3.1.0 Snippet by shehzadali110

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="main_container">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Bootstrap Custom TimeRangePicker</h3>
</div>
<div class="panel-body">
<div class="form-group">
<div class="Data_Group">
<div id="datetimepickerDate" class="timerange">
<i class="fa fa-clock-o date-icon" aria-hidden="true"></i>
<label for="start_time">Time Range Picker</label>
<input type="text" class="form-control" name="start_time" placeholder="e.g 01:00 PM to 02:00 PM" id="start_time" data-placeholder="Select Time" />
<span class="input-feedback" data-id="start_time"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css");
.main_container{
margin: 80px auto;
}
.main_container .row{
display: flex;
align-items: center;
justify-content: center;
}
.timerangepicker-container {
display: flex;
position: absolute;
width: 230px;
z-index: 999;
}
.timerangepicker-container .timerangepicker-label {
font-size: 12px;
display: block;
line-height: 2em;
padding-left: 1em;
background: #f2f3f3;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.timerangepicker-container .timerangepicker-from {
border: 1px solid #ddd;
background: #fff;
border-right: none;
padding-bottom: 10px;
}
.timerangepicker-container .timerangepicker-to {
border: 1px solid #ddd;
background: #fff;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
jQuery(document).ready(function($) {
$("body").on("click", ".timerange", function(e) {
e.stopPropagation();
var input = $(this).find("input");
var now = new Date();
var hours = now.getHours();
var period = "PM";
if (hours < 12) {
period = "AM";
} else {
hours = hours - 11;
}
var minutes = now.getMinutes();
var range = {
from: {
hour: hours,
minute: minutes,
period: period,
},
to: {
hour: hours,
minute: minutes,
period: period,
},
};
input.val("");
if (input.val() !== "") {
var timerange = input.val();
var matches = timerange.match(/([0-9]{2}):([0-9]{2}) (\bAM\b|\bPM\b)-([0-9]{2}):([0-9]{2}) (\bAM\b|\bPM\b)/);
if (matches.length === 7) {
range = {
from: {
hour: matches[1],
minute: matches[2],
period: matches[3],
},
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: