Bootstrap daterangepicker dual-calendar time period Selection control details, daterangepicker dual-day
Double calendar time period selection plug-in-daterangepicker is a later time control of the bootstrap framework. You can set multiple time period options or customize the time period. You can select the start time and end time by yourself, the maximum time span can be set in the program. The Bootstrap version used in our project is 2.3.1, So I integrated daterangepicker with Bootstrap-2.3.1.
I. css and js to be introduced
<link href="bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" media="all" href="daterangepicker-bs3.css" /> <link rel="stylesheet" type="text/css" media="all" href="daterangepicker-1.3.7.css" /> <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet"> <script type="text/javascript" src="jquery-1.10.1.min.js"></script> <script type="text/javascript" src="bootstrap.min.js"></script> <script type="text/javascript" src="moment.js"></script> <script type="text/javascript" src="daterangepicker-1.3.7.js"></script>
Ii. html code
<Div class = "page-content"> <! -- Begin page container --> <div class = "container-fluid"> <div class = "row-fluid" style = "margin-top: 5px "> <div class =" span4 "> <div class =" control-group "> <label class =" control-label "> date: </label> <div class = "controls"> <div id = "reportrange" class = "pull-left dateRange" style = "width: 350px "> <I class =" glyphicon-calendar fa-calendar "> </I> <span id =" searchDateRange "> </span> <B class =" caret "> </B> </div>
3. Call daterangepicker using js
<Script type = "text/javascript"> $ (document ). ready (function () {// time plug-in $ ('# reportrange span'{.html (moment (). subtract ('urs', 1 ). format ('yyyy-MM-DD HH: mm: ss') + '-' + moment (). format ('yyyy-MM-DD HH: mm: ss'); $ ('# reportrange '). daterangepicker ({// startDate: moment (). startOf ('day'), // endDate: moment (), // minDate: '2017/123', // minimum time maxDate: moment (), // maximum dateLimit: {days: 30}, // maximum interval between start and end times showDropdowns: true, showWeekNumbers: false, // whether to display the timePicker of the week: true, // whether to display hour and minute timePickerIncrement: 60, // time increment, in the unit of minute timePicker12Hour: false, // whether to use 12-hour to display time ranges: {// 'last hour ': [moment (). subtract ('urs', 1), moment ()], 'day': [moment (). startOf ('day'), moment ()], 'Yesterday ': [moment (). subtract ('days ', 1 ). startOf ('day'), moment (). subtract ('days ', 1 ). endOf ('day')], 'last 7 Day': [moment (). subtract ('days ', 6), moment ()], 'last 30 Day': [moment (). subtract ('days ', 29), moment ()]}, opens: 'right', // the pop-up location of the date selection box buttonClasses: ['btn btn-default'], applyClass: 'btn-small btn-primary Blue', cancelClass: 'btn-small', format: 'yyyy-MM-DD HH: mm: ss ', // separator: 'to', locale: {applyLabel: 'OK', cancelLabel: 'cancel', fromLabel: 'start time ', toLabel: 'End time', mrmrangelabel: 'custom', daysOfWeek: ['day', 'yi', '2', '3', '4 ', '5', '6'], monthNames: ['August 11', 'August 11', 'August 11', 'August 11', 'August 30', 'August 30 ', 'October ', 'October'], firstDay: 1 }}, function (start, end, label) {// format the date display box $ ('# reportrange span'{.html (start. format ('yyyy-MM-DD HH: mm: ss') + '-' + end. format ('yyyy-MM-DD HH: mm: ss');}); // set the date menu to be option -- start --/* var dateOption; if ("$ {riqi}" = 'day') {dateOption = "today";} else if ("$ {riqi}" = 'yday ') {dateOption = "yesterday";} else if ("$ {riqi}" = 'Week ') {dateOption = "last 7 days ";} else if ("$ {riqi}" = 'month') {dateOption = "last 30 days";} else if ("$ {riqi}" = 'Year ') {dateOption = "last year";} else {dateOption = "Custom" ;}$ (". daterangepicker "). find ("li "). each (function () {if ($ (this ). hasClass ("active") {$ (this ). removeClass ("active");} if(dateoption###(this#.html () {$ (this ). addClass ("active") ;}}); * // set the date menu to be selected -- end --}) </script>
IV,
V. Instances
Bootstrap daterangepicker
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.