Bootstrap year picker example using datepicker js
In this post we will give you information about Bootstrap year picker example using datepicker js. Hear we will give you detail about Bootstrap year picker example using datepicker jsAnd how to use it also give you demo for it if it is necessary.
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:
Example:
<html lang="en">
<head>
<title>Bootstrap - year picker only example</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
</head>
<body>
<div >
<h2>Bootstrap - year picker only example</h2>
<input style="width: 300px;" type="text">
<script type="text/javascript">
$('.date-own').datepicker({
minViewMode: 2,
format: 'yyyy'
});
</script>
</div>
</body>
</html>
Hope this code and post will helped you for implement Bootstrap year picker example using datepicker js. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs