我想创建具有预定义日期的单个日期选择器,因为它可以使用范围。因此,如果用户点击它,它将显示预定义的值(如今天的8个时钟和明天的那个时钟)以及选择日期和时间自定义的可能性。
我在examples中没有看到这样的应用程序,但由于daterangepicker的用例非常简单,我相信它应该在某种程度上可行。
我能做的最接近的事情是跟随,但预定义的仍然是范围而不是单个日期
$('#demo').daterangepicker({
"singleDatePicker": true,
"showDropdowns": true,
"showWeekNumbers": true,
"timePicker": true,
"timePicker24Hour": true,
"autoApply": true,
"ranges": {
"Today": [
"2016-02-10T19:32:41.307Z",
"2016-02-10T19:32:41.307Z"
],
"Yesterday": [
"2016-02-09T19:32:41.307Z",
"2016-02-09T19:32:41.307Z"
],
"Last 7 Days": [
"2016-02-04T19:32:41.307Z",
"2016-02-10T19:32:41.307Z"
],
"Last 30 Days": [
"2016-01-12T19:32:41.307Z",
"2016-02-10T19:32:41.307Z"
],
"This Month": [
"2016-01-31T23:00:00.000Z",
"2016-02-29T22:59:59.999Z"
],
"Last Month": [
"2015-12-31T23:00:00.000Z",
"2016-01-31T22:59:59.999Z"
]
},
"startDate": "02/04/2016",
"endDate": "02/10/2016"
}, function(start, end, label) {
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
});