Saturday, June 1, 2024
184
rated 0 times [  189] [ 5]  / answers: 1 / hits: 132897  / 12 Years ago, mon, october 29, 2012, 12:00:00

I am using the following code to display only the years:



$(#datepicker).datepicker( {viewMode: years, minViewMode: years});


but input appears in the format dd/mm/yyyy



How can I solve this since I do not have the format yyyy?


More From » twitter-bootstrap

 Answers
15

Try this





$(#datepicker).datepicker({
format: yyyy,
viewMode: years,
minViewMode: years
});

<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>
<script src=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js></script>
<link href=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.css rel=stylesheet/>
<script src=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js></script>
<link href=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css rel=stylesheet/>


<input type=text id=datepicker />





$(#datepicker).datepicker( {
format: yyyy, // Notice the Extra space at the beginning
viewMode: years,
minViewMode: years
});

[#82288] Saturday, October 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cadendericki

Total Points: 482
Total Questions: 109
Total Answers: 103

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
cadendericki questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Wed, Jul 8, 20, 00:00, 4 Years ago
Thu, May 14, 20, 00:00, 4 Years ago
;