Setting format and value in input type="date"
The format is YYYY-MM-DD
. You cannot change it.
$('#myinput').val('2013-12-31');
sets value
new Date().toISOString().split('T')[0];
try this :)
function getDefaultDate(){
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
return today;
}
$(document).ready(function(){
$("#dateid").val( getDefaultDate());
});