I have this code that changes the format of dates. I would like to know how can I make ISO format the default so that every time someone picks a date it gets formatted in ISO8601 yy-mm-dd
format without needing to select again. This is because it only assumes the format if I select another option then go back to the previous.
<script>
$(function() {
$("#datepicker").datepicker();
$("#format").on("change", function() {
$("#datepicker").datepicker("option", "dateFormat", $(this).val());
});
});
</script>
<p>
Date: <input type="text" id="datepicker" size="30">
</p>
<p>
Format options:<br>
<select id="format">
<option value="yy-mm-dd" selected>ISO 8601 - yy-mm-dd</option>
<option value="d M, y">Short - d M, y</option>
</select>