Zihao

Make small but daily progress

0%

DateRangePicker 中文化以及老版本的一些初始化问题,不能选择秒的问题

实用的DateRangePicker 中文化脚本。解决选择秒的问题。

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
$('#headlineAddForm #rangeTime').daterangepicker({  
showDropdowns : true,
timePicker : true, //是否显示小时和分钟
timePicker24Hour: true,
timePickerIncrement : 1, //时间的增量,单位为分钟
timePickerSeconds : true,
linkedCalendars : false,
locale : {
format: "YYYY-MM-DD HH:mm:ss", //控件中from和to 显示的日期格式
separator : " - ",
applyLabel : "确定",
cancelLabel : "取消",
fromLabel : "开始",
toLabel: "结束",
customRangeLabel : "自定义",
weekLabel : "W",
daysOfWeek : ["日", "一", "二", "三", "四", "五", "六"],
monthNames : ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月 "],
firstDay : 1
}
}, function(start, end, label) {
$("#headlineAddForm #startTime").val(start.unix());
$("#headlineAddForm #endTime").val(end.unix());
}).on('hide.daterangepicker', function() {
$('#headlineAddForm').data('bootstrapValidator').updateStatus('rangeTime', 'NOT_VALIDATED',null).validateField('rangeTime');
}).on('cancel.daterangepicker', function() {
$('#headlineAddForm #rangeTime').val("");
$('#headlineAddForm').data('bootstrapValidator').updateStatus('rangeTime', 'NOT_VALIDATED',null).validateField('rangeTime');
}).on('apply.daterangepicker', function() {
if($.trim($("#headlineAddForm #startTime").val()).length == 0) {
$('#headlineAddForm #rangeTime').val("");
$('#headlineAddForm').data('bootstrapValidator').updateStatus('rangeTime', 'NOT_VALIDATED',null).validateField('rangeTime');
}
});
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
$('#headlineModifyForm #rangeTime').daterangepicker({  
showDropdowns : true,
timePicker : true, //是否显示小时和分钟
timePicker24Hour: true,
timePickerIncrement : 1, //时间的增量,单位为分钟
timePickerSeconds : true,
linkedCalendars : false,
locale : {
format: "YYYY-MM-DD HH:mm:ss", //控件中from和to 显示的日期格式
separator : " - ",
applyLabel : "确定",
cancelLabel : "取消",
fromLabel : "开始",
toLabel: "结束",
customRangeLabel : "自定义",
weekLabel : "W",
daysOfWeek : ["日", "一", "二", "三", "四", "五", "六"],
monthNames : ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月 "],
firstDay : 1
}
}, function(start, end, label) {
$("#headlineModifyForm #startTime").val(start.unix());
$("#headlineModifyForm #endTime").val(end.unix());
}).on('hide.daterangepicker', function() {
$('#headlineModifyForm').data('bootstrapValidator').updateStatus('rangeTime', 'NOT_VALIDATED',null).validateField('rangeTime');
});

欢迎关注我的其它发布渠道