这是我的java脚本,我希望日期为2017年6月3日 - 我无法做到这一点请给我解决方案。
<div class="form-group" >
<div class='input-group date' >
<input type='text' class="form-control" id='datetimepicker1' />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script>
$(document).ready(function(){
$('#datetimepicker1').datepicker();
format:
});
</script>
如何使用格式?.i搜索它但我没有得到解决方案,任何人都可以给我解决方案。
答案 0 :(得分:2)
根据documentation,您可以使用M
中的MM
或format
获取月份名称(在jsfiddle上试用):
<div class="form-group" >
<div class='input-group date' >
<input type='text' class="form-control" id='datetimepicker1' />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script>
$(document).ready(function(){
$('#datetimepicker1').datepicker({
format: 'dd-MM-yyyy'
});
});
</script>
答案 1 :(得分:-1)
<script>
$(document).ready(function(){
$('.datepicker').datepicker({
format: 'dd/mm/yyyy'
});
</script>
或强>
$("#datepicker").datepicker( {
format: "dd-mm-yyyy",
viewMode: "months",
minViewMode: "months"
});
或强>
$("#datepicker").datepicker({ dateFormat: "d M,y" });
答案 2 :(得分:-1)
将'dd-MM-yyyy'
字符串用于format option值。您可以使用下面的代码段尝试此解决方案。
$('#datetimepicker1').datepicker({format:'dd-MM-yyyy'});
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<div class="form-group">
<div class='input-group date'>
<input type='text' class="form-control" id='datetimepicker1' />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
&#13;