==》上次介绍了bootstrap框架日期时间 开始日期和结束日期选择 http://www.cnblogs.com/wjqblogs/p/4043198.html
今天又做了个只选择年月的日期选择,而且对其进行汉化,如下:
引入js
1 jQuery.min.js 2 bootstrap.min.js 3 bootstrap-datetimepicker.min.js 4 bootstrap-datetimepicker.zh-CN.js
html
1 <input class="form-control" name="sdate" value="${sdate}" type="text" style="width:100px" id="sdate" data-date-format="yyyy-mm" readonly>
jQuery
1 $('#sdate').datetimepicker({ 2 format: 'yyyy.mm', 3 weekStart: 1, 4 todayBtn: 0, 5 autoclose: 1, 6 startView: 3, 7 minView:3, 8 language: 'zh-CN', 9 forceParse: 1, 10 showMeridian: 1 11 });
另:汉化bootstrap-datetimepicker.zh-CN.js文件
1 ;(function($){ 2 $.fn.datetimepicker.dates['zh-CN'] = { 3 days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"], 4 daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"], 5 daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"], 6 months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], 7 monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], 8 today: "今日", 9 suffix: [], 10 meridiem: ["上午", "下午"] 11 }; 12 }(jQuery));