Date and Time
Date and Time
The date and time picker allows a user to select a single point in time or a time range. Time can be expressed as a date, a time of day, or a combination of both. Common use cases are selecting a date and time for something to run or expire and filtering events by their timestamp. The date and time picker is based on the Bootstrap-datetimepicker. See the bootstrap-datepicker doc for complete documentation.
There are number of variation of the date and Time picker. We recommend using appropriate component to meet specific user case, jump to a section below for applied examples: </br>
- As a user, I want to set a single date
- As a user, I want to set a single time
- As a user, I want to set single date and time in combination
- As a user, I want to filter or search for items by a range of dates
- As a user, I want to filter or search for items by date and time in combination
DatePicker
The DatePicker allows a user to select a single date.

TimePicker
The TimePicker allows a user to select a single Time.

DateTimePicker
The DateTimePicker allows a user to select a date with a time.

DateRangePicker
The DateRangePicker allows a user to select a range of date.

DateTimeRangePicker
The DateTimeRangPicker allows a user to select a range of date with time.

Date and Time
Date and Time picker has a number of variations, jump to a section below for applied examples:
DatePicker

-
Input Field: The datepicker field is read only due to the limitations of the input validation.
-
Calendar Icon: The calendar icon is shown on the right.
-
Calendar: The calendar is displayed when the user clicks on the input field.
-
Today Button: This button is a shortcut to select today’s date.
-
Today indicator: Today indicator: The indication of Today’s date.
-
Month and Year Switch: Change the view of the calendar to month or year by clicking on the calendar header.
-
Previous and Next Buttons: Allows the user to navigate through the months or years.
TimePicker

-
Input Field: The Timepicker field is read only due to the limitations of the input validation.
-
Time Icon: The time icon is shown on the right.
-
Time: The Time is displayed when the user clicks on the input field.
-
AM and PM Buttons: Allows the user to toggle between AM and PM.
-
Select Hour: Use the picker to select the hour.
-
Select Minute: Use the picker to select the minute.
-
Up and Down Buttons: Allows the user to step through the hours or minutes.
DateTimePicker

DateTimePicker is a combination of DatePicker and TimePicker. Refer to the DatePicker and TimePicker for more details about design guidance.
-
Input Field: The DateTimepicker field is read only due to the limitations of the input validation.
-
DateTimePicker: The DateTimePicker is displayed when the user clicks on the input field.
DateRangePicker

DateRangePicker is a combination of two DatePickers. Refer to the DatePicker for more details about design guidance.
-
StartDate Input Field: When the user clicks on the StartDate Input Field, the calendar is display for selecting a StartDate.
-
EndDate Input Field: When the user clicks on the EndDate Input Field, the calendar is display for selecting an EndDate.
Selecting Predefined Ranges

- Predefined Range (optional): This action allow user to quickly select some predefined ranges, such as : 7 days, 15 days, 30 days… The Options available in the dropdown menu may be any number of days.
-
When both the StartDate and the EndDate field are empty, user clicks “7 days “, the date range selected will be 7 days starting from Today’s date.
-
When the StartDate is filled, user clicks “7 days “, the date range selected will be 7 days after the StartDate.
-
When the EndDate is filled, user clicks “7 days “, the date range selected will be 7 days before the EndDate.
DateTimeRangePicker

DateTimeRangePicker is a combination of Two DateTimePickers. Refer to the DateTimePicker for more details about design guidance.
-
StartDate Input Field: When the user clicks on the StartDate Input Field, the DateTimePicker is display for selecting a StartDate and Time.
-
EndDate Input Field: When the user clicks on the EndDate Input Field, the DateTimePicker is display for selecting an EndDate and Time.
- View Angular PatternFly Example
- View PatternFly NG Example
- View PatternFly React Example
PatternFly Core Example
Jump to DatePicker, TimePicker, DateTimePicker, DateRangePicker, DateTimeRangePicker
DatePicker
<script src="components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<script src="components/moment/min/moment.min.js"></script>
<div class="input-group date-time-picker-pf" id="datetimepicker1">
<input type="text" class="form-control">
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
<script>
$(function () {
$('#datetimepicker1').datetimepicker({
format: 'L',
allowInputToggle: true,
showTodayButton: true,
icons: {
today: 'today-button-pf'
}
});
});
</script>
TimePicker
<script src="components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<script src="components/moment/min/moment.min.js"></script>
<div class="input-group date-time-picker-pf" id="datetimepicker2">
<input type="text" class="form-control">
<span class="input-group-addon">
<span class="fa fa-clock-o"></span>
</span>
</div>
<script>
$(function () {
$('#datetimepicker2').datetimepicker({
format: 'LT',
allowInputToggle: true,
keyBinds: {
enter: function () {
this.hide();
}
}
});
});
</script>
DateTimePicker
<script src="components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<script src="components/moment/min/moment.min.js"></script>
<div class="input-group date-time-picker-pf" id="datetimepicker3">
<input type="text" class="form-control"/>
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
<script>
$(function () {
$('#datetimepicker3').datetimepicker({
allowInputToggle: true,
showTodayButton: true,
toolbarPlacement: 'bottom',
sideBySide: true,
icons: {
today: 'today-button-pf'
}
});
});
</script>
DateRangePicker
<script src="components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<script src="components/moment/min/moment.min.js"></script>
<div class="date-time-range-picker-pf input-group" id="range1">
<input type="text" class="form-control" id="datetimepicker4">
<span class="input-group-addon">To</span>
<input type="text" class="form-control" id="datetimepicker5">
<div class="dropdown btn-group dropdown-kebab-pf">
<button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="fa fa-ellipsis-v"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownKebab">
<li><a href="#!">7 days</a></li>
<li><a href="#!">15 days</a></li>
<li><a href="#!">30 days</a></li>
<li><a href="#!">90 days</a></li>
</ul>
</div>
</div>
<script>
$(function () {
var $startDate = $('#datetimepicker4');
var $endDate = $('#datetimepicker5');
$startDate.datetimepicker({
format: 'L',
showTodayButton: true,
icons: {
today: 'today-button-pf'
}
});
$endDate.datetimepicker({
format: 'L',
useCurrent: false,
showTodayButton: true,
icons: {
today: 'today-button-pf'
}
});
$startDate.on('dp.change', function (e) {
$endDate.data('DateTimePicker').minDate(e.date);
});
$endDate.on('dp.change', function (e) {
$startDate.data('DateTimePicker').maxDate(e.date);
});
$('#range1').on('click', 'a', function (e) {
var sDate = $startDate.data('DateTimePicker').date();
var eDate = $endDate.data('DateTimePicker').date();
var duration = parseInt(e.target.textContent);
if (!sDate && !eDate) {
$startDate.data('DateTimePicker').date(moment());
$endDate.data('DateTimePicker').date(moment().add(duration, 'days'));
} else if (sDate && !eDate) {
$endDate.data('DateTimePicker').date(sDate.add(duration, 'days'));
} else if (!sDate && eDate) {
$startDate.data('DateTimePicker').date(eDate.subtract(duration, 'days'));
} else {
$endDate.data('DateTimePicker').minDate(false);
$endDate.data('DateTimePicker').date(sDate.add(duration, 'days'));
}
});
});
</script>
DateTimeRangePicker
<script src="components/eonasdan-bootstrap-datetimepicker/src/js/bootstrap-datetimepicker.js"></script>
<script src="components/moment/min/moment.min.js"></script>
<div class="date-time-range-picker-pf input-group">
<input type="text" class="form-control" id="datetimepicker6">
<span class="input-group-addon">To</span>
<input type="text" class="form-control" id="datetimepicker7">
</div>
<script>
$(function () {
var $startDate = $('#datetimepicker6');
var $endDate = $('#datetimepicker7');
$startDate.datetimepicker({
showTodayButton: true,
toolbarPlacement: 'bottom',
sideBySide: true,
icons: {
today: 'today-button-pf'
}
});
$endDate.datetimepicker({
useCurrent: false,
showTodayButton: true,
toolbarPlacement: 'bottom',
sideBySide: true,
icons: {
today: 'today-button-pf'
}
});
$startDate.on('dp.change', function (e) {
$endDate.data('DateTimePicker').minDate(e.date);
});
$endDate.on('dp.change', function (e) {
$startDate.data('DateTimePicker').maxDate(e.date);
});
});
</script>