Bootstrap Year Picker using Datepicker JS Example

By Hardik Savani June 12, 2023 Category : Bootstrap

Generally we are use datepicker with dd-mm-yyyy format but sometimes we require to get only year, i mean select only year at that time we need to use datepicker option like format, minViewMode etc that way we can make datepicker into year picker for us.

In this example i give you how can you get year picker, so i use two option from datepicker function one format and other minViewMode, by default minViewMode is for datepicker, if you use 1 then it is for month picker and 2 for year picker, so let's run bellow example or you can see demo as well:


<html lang="en">


<title>Bootstrap - year picker only example</title>

<link href="" rel="stylesheet">

<link href="" rel="stylesheet">

<script src=""></script>

<script src=""></script>

<script src=""></script>



<div class="container text-center">

<h2>Bootstrap - year picker only example</h2>

<input class="date-own form-control" style="width: 300px;" type="text">

<script type="text/javascript">


minViewMode: 2,

format: 'yyyy'