0

I want my datetimepicker dialog box to set limit to next 365 days(1 year). How can I get this using Jquery. here is my code.

$('.dt-expiry-date-time').datetimepicker({
    dayOfWeekStart: 1,
    format: 'Y-m-d H:i:s',
    lang: 'en',
    startDate: new Date(),
    step: 5,
    minDate: new Date(),
});

Please help me with this.

2 Answers2

0

Use maxDate: 365 in your jquery date picker configuration. This will automatically sets the maximum date to 365 days from current date.

$("#datepicker").datepicker({
    maxDate: 365
});

$(function () {
    $("#datepicker").datepicker({
        maxDate: 365
    });
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Date:
    <input type="text" id="datepicker">
</p>
Nitheesh
  • 19,238
  • 3
  • 22
  • 49
0

Finally solved the issue.. here is the code.

 $('.dt-expiry-date-time').datetimepicker({
    dayOfWeekStart: 1,
    format: 'Y-m-d H:i:s',
    lang: 'en',
    startDate: new Date(),
    step: 5,
    minDate: '-1970/01/01',
    maxDate: '+1970/12/31'
});