bootstrap-timepicker 设置不同的时间格式
直接上代码:
//选择年月日的 startView: 2, minView: 2, format: 'yyyymmdd', $('#datetimepicker').datetimepicker({ format: 'yyyymmdd', weekStart: 1, autoclose: true, startView: 2, minView: 2, forceParse: false, language: 'zh-CN' });
//选择年月的 startView: 3, minView: 3, format: 'yyyymm', $('#datetimepicker').datetimepicker({ format: 'yyyymm', weekStart: 1, autoclose: true, startView: 3, minView: 3, forceParse: false, language: 'zh-CN' });
//选择年的 startView: 4, minView: 4, format: 'yyyy', $('#datetimepicker').datetimepicker({ format: 'yyyymm', weekStart: 1, autoclose: true, startView: 4, minView: 4, forceParse: false, language: 'zh-CN' });
<input type="text" name="type" class="form-control" id="datetimepicker" placeholder="请选择日期">
在这里遇到很多问题:什么日历图标没反映啊,输入框和日历图标对不齐啊,点日历图标把数据清了啊……都是样式问题,所以提供几种样式,一种一种试吧……博大精深啊……
<div class='input-group date form_date' data-date-format="yyyymmdd">
<input name="startTm" id="startTm" type='text' class="form-control input-sm" readonly="readonly"/>
<span class="input-group-addon input-sm">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
<div class="date input-append" id="datetimepicker">
<div class="input-group">
<input class="form-control input-sm" readonly="readonly" type="text">
<span class="add-on input-group-addon"><i class="icon-remove"></i></span>
<span class="add-on input-group-addon"><i class="icon-th"></i></span></div>
</div>