How to Change View Mode in Bootstrap Datepicker Like yyyy-mm?
When i was working on my laravel application and i need use datepicker picker but i require only select year and month because i have to filter with onlt selected month and year. I did search lot and also check options of datepicker js but i can't do it that because i was wrong maybe.
But at last found minViewMode option of datepicker library and i did that if you also want to make format like mm-yyyy or yyyy-mm then you can set minviewmode this way :
Example:
<html lang="en">
<head>
<title>Bootstrap - datepicker change view mode like yyyy-mm</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 class="container text-center">
<h2>Bootstrap - datepicker change view mode like yyyy-mm</h2>
<input class="date-own form-control" style="width: 300px;" type="text">
<script type="text/javascript">
$('.date-own').datepicker({
minViewMode: 1,
format: 'yyyy-mm'
});
</script>
</div>
</body>
</html>
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Bootstrap Datepicker Disable Specific Dates Example
- Bootstrap Datepicker Disable Saturday and Sunday Example
- How to use datepicker in vuejs?
- Bootstrap Datepicker Trigger Change Event Example
- Bootstrap Datepicker Get Date on Change Event Example
- PHP Ajax Inline Editing using X-editable Bootstrap JS Example
- Bootstrap Year Picker using Datepicker JS Example
- AngularJS Simple Datepicker Directive Example Tutorial
- JQuery Datepicker Example using JQuery UI JS
- Bootstrap Datepicker Change Date Format Example
- Bootstrap Timepicker using Datetimepicker JS Example
- JQuery Delete Confirm Modal using Bootbox Example
- How to Add Dialog Box in Bootstrap?