twitter-bootstrap Bootstrap-DatePicker 的自定义日期格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17896176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Custom Date Format for Bootstrap-DatePicker
提问by Cataclysm
Can anyone guide me for formatting date in Bootstrap-DatePicker.
谁能指导我在Bootstrap-DatePicker 中格式化日期。
And I used Eternicode/bootstrap-datepicker. Here my codes at JSP..
我使用了Eternicode/bootstrap-datepicker。这是我在 JSP 上的代码..
<div>Date : </div>
<input type="text" style="width: 213px;" class="datepicker" >
And at my JavaScript file...
在我的 JavaScript 文件中...
$('.datepicker').datepicker({
format: 'dd/mm/yyyy (D)',
autoclose: true,
keyboardNavigation : true ,
endDate : dateFormat(date, "dd/mm/yyyy (ddd)"),
daysOfWeekDisabled : [0]
});
Output that I want to get as like 27/07/2013 (Sat).
我想获得的输出类似于27/07/2013 (Sat)。
But output that show from my code as 27/07/2013 (Sat
但是从我的代码中显示的输出为27/07/2013 (Sat
I can't see close bracket " ) ". Any Suggestions ? Thanks in advance for all...
我看不到右括号“)”。有什么建议 ?预先感谢所有...
采纳答案by amatellanes
I'm sure you are using a old version. You must use the last version available at master branch:
我确定您使用的是旧版本。您必须使用 master 分支上可用的最新版本:
回答by Developer
Perhaps you can check it here for the LATEST version always
也许您可以随时在此处查看最新版本
http://bootstrap-datepicker.readthedocs.org/en/latest/
http://bootstrap-datepicker.readthedocs.org/en/latest/
$('.datepicker').datepicker({
format: 'mm/dd/yyyy',
startDate: '-3d'
})
or
或者
$.fn.datepicker.defaults.format = "mm/dd/yyyy";
$('.datepicker').datepicker({
startDate: '-3d'
})
回答by Diego
I solve it editing the file bootstrap-datapicker.js.
我解决它编辑文件 bootstrap-datapicker.js。
Look for the text bellow in the file and edit the variable "Format:"
在文件中查找下面的文本并编辑变量“格式:”
var defaults = $.fn.datepicker.defaults = {
assumeNearbyYear: false,
autoclose: false,
beforeShowDay: $.noop,
beforeShowMonth: $.noop,
beforeShowYear: $.noop,
beforeShowDecade: $.noop,
beforeShowCentury: $.noop,
calendarWeeks: false,
clearBtn: false,
toggleActive: false,
daysOfWeekDisabled: [],
daysOfWeekHighlighted: [],
datesDisabled: [],
endDate: Infinity,
forceParse: true,
format: 'dd/mm/yyyy',
keyboardNavigation: true,
language: 'en',
minViewMode: 0,
maxViewMode: 4,
multidate: false,
multidateSeparator: ',',
orientation: "auto",
rtl: false,
startDate: -Infinity,
startView: 0,
todayBtn: false,
todayHighlight: false,
weekStart: 0,
disableTouchKeyboard: false,
enableOnReadonly: true,
showOnFocus: true,
zIndexOffset: 10,
container: 'body',
immediateUpdates: false,
title: '',
templates: {
leftArrow: '«',
rightArrow: '»'
}
};
回答by WinHtaikAung
var type={
format:"DD, d MM, yy"
};
$('.classname').datepicker(type.format);

