How to update date in date picker??





--> Most important thing while updating date in date picker is Date Format. Date format should be like yyyy-mm-dd. If it is not then date picker will not accept it. so first it should be convert to it using toISOString() method.

<input type="date" id='mydate'>
<button onclick="setcurrentdate()">Set Today's Date</button>

<script>
function setcurrentdate()
{
var date = new Date();
var date1 = date.toISOString().substring(0,10)
document.getElementById("mydate").value = date1;
}
</script>

Comments

Popular posts from this blog

how to save images with angular nodejs

How to restrict your logged In page in angular (authentication guard)

How to notify about data update to other component.