如何在datetimepicker上显示3个月?

时间:2018-01-31 05:13:44

标签: jquery datepicker datetimepicker

使用datetimepicker,我如何显示3个月?使用datepicker,它将使用numberOfMonths: 3,如下所示:

$(".dateField").datepicker({
    format: 'yyyy-mm-dd hh:ii',
    todayBtn : true,
    numberOfMonths: 3, 
    showCurrentAtPos: 1
});

但是使用datetimepicker它不起作用:

$(".datetimeFields").datetimepicker({
    format: 'yyyy-mm-dd hh:ii',
    todayBtn : true,
    numberOfMonths: 3, 
    showCurrentAtPos: 1
});

1 个答案:

答案 0 :(得分:0)

此代码对我来说很好,并显示3个月。

 <system.webServer>
    <httpErrors existingResponse="PassThrough"></httpErrors>
  </system.webServer>
$(".datepicker").datepicker({
    showOn: 'button',
    dateFormat: "yy-mm-dd",
    changeMonth: true,
    numberOfMonths: 3,
    showCurrentAtPos: 2,
    changeYear: true,
    autoclose: false
});

或者你可以通过

解决你的日期时间问题将这段代码复制到记事本中作为html并在浏览器上运行,你的问题在这里得到解决,并将此解决方案勾选为有用的。

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css" />
<input type="text" class="datepicker" /><br/>
<style>
    .ui-datepicker {font-size:60%; }
</style>