Hisanth
Hisanth

Reputation: 62

How to Set Year in Jquery Date Picker

$(document).ready(function () {
        $("#<%=txtDate.ClientID %>").datepicker({
            dateFormat: 'dd-mm-yy',
            changeMonth: true,
            changeYear: true
        }).datepicker("setDate", "0"); });

It shows Current Date (16-02-2016). But I need to Set 2016 as 2017.

How to Set the Year?

Upvotes: 3

Views: 5771

Answers (1)

Victor1125
Victor1125

Reputation: 692

$(document).ready(function () {
    var today=new Date();
    $("#<%=txtDate.ClientID %>").datepicker({
        dateFormat: 'dd-mm-yy',
        changeMonth: true,
        changeYear: true
    }).datepicker("setDate", new Date(today.getFullYear()+1, today.getMonth(), today.getDate())); });

Upvotes: 2

Related Questions