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 export data to excel sheet with colors and style in angular.

How to add splash screen and app icon with ionic capacitor angular android app