【发布时间】:2017-05-19 17:27:56
【问题描述】:
我在我的代码中使用引导日期选择器,但出现的日历中有月份,如“三月”、“七月”等。有没有办法将月份全名更改为“三月”、“七月”。 提前致谢 See the image 在这我希望八月是八月
【问题讨论】:
我在我的代码中使用引导日期选择器,但出现的日历中有月份,如“三月”、“七月”等。有没有办法将月份全名更改为“三月”、“七月”。 提前致谢 See the image 在这我希望八月是八月
【问题讨论】:
由于您在 cmets 中声明您使用的是 eonasdan datetimepicker,因此您可以简单地使用 dayViewHeaderFormat 选项。
这是一个工作示例。
$('#datetimepicker1').datetimepicker({
format: 'L',
dayViewHeaderFormat: 'MMM YYYY'
});
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment-with-locales.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
【讨论】:
翻译成你想要的任何东西:
...只需向 $.fn.datepicker.dates 添加一个键, 在调用 .datepicker() docs
之前
$.fn.datepicker.dates['en'] = {
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
today: "Today",
clear: "Clear",
format: "mm/dd/yyyy",
titleFormat: "MM yyyy", /* Leverages same syntax as 'format' */
weekStart: 0
};
http://bootstrap-datepicker.readthedocs.io/en/latest/i18n.html
更改语言:
$('.datepicker').datepicker({
language: "pt-BR"
});
【讨论】:
$('.datepicker').datepicker({});
MMM 值,虽然这是momentjs 月份的简称