Search code examples
jquerytwitter-bootstrapbootstrap-datetimepicker

Showing Calender Years only in input field with bootstrap datetimepicker


I am using Bootstrap datetimepicker (can see here)

I have bunch of input fields attached with this datetimepicker, these are working fine to show only dates,time and datetime as well.

I wana to show only the "years" in the input field and datetimepicker popup as well, user can only navigate years list and select an year to be showing in the input field.

Is there any way to achieve this thing using this plugin?


Solution

  • You can have it by simply defining the datetimepicker as below

    $('Your selector').datetimepicker({
        format      :   "YYYY",
        viewMode    :   "years", 
    });
    

    Please find below link to JSFiddle Working demo

    https://jsfiddle.net/2n4pnrf1/