I am using bootstrap datepicker and I only show the years. When I load the page, I would like to set a default year, tried the following but the current year (2018) is hightlited instead.
$('#sandbox-container div').datepicker({
format: "yyyy",
viewMode: "years",
minViewMode: "years",
updateViewDate: false,
changeYear: true,
defaultDate: '2014'
});
Thing is this is an Edit page, so the year is coming from the db, therefore I need to be able to set a default year as per the value I am getting from the db.
I had to change updateViewDate: false
into updateViewDate: true,
so:
$('#sandbox-container div').datepicker({
format: "yyyy",
viewMode: "years",
minViewMode: "years",
updateViewDate: true,
changeYear: true,
defaultViewDate: {year: '2014'}
});