I'm using bootstrap 4 latest version for develop my php web application and I'm using html 5 "date" input for enter dates in html forms. Bootstrap 4 always show date format as mm/dd/yyyy in date input fields. I need to change it to yyyy-mm-dd. How can I change default date format to my own format in bootstrap 4 date picker?
Asked
Active
Viewed 1.8k times
1
-
take a look here:https://stackoverflow.com/questions/30494086/how-to-format-the-bootstrap-datepicker-for-php – לבני מלכה Jun 17 '18 at 06:05
-
Tks. But there is no solution for my problem. I'm using bootstrap 4 native date picker. I need to change it's format. – dinith Jun 17 '18 at 06:19
-
can you do this using jquery?? – לבני מלכה Jun 17 '18 at 06:21
2 Answers
2
Use data-date-format="yyyy/mm/dd"
$(function() {
$("#datepicker").datepicker({
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="container">
<input data-date-format="yyyy/mm/dd" id="datepicker">
</div>

לבני מלכה
- 15,925
- 2
- 23
- 47