+ 1

How to get value from input type date?

15th Mar 2018, 3:03 PM
Harshit Kumar
Harshit Kumar - avatar
2 Answers
+ 2
Hi Harshit Your HTML <form> Birthday: <input id="datePicker" type="date" name="bday"> </form> Your JS window.onload=function(){ document.getElementById("datePicker").addEventListener("change", function() { var input = this.value; var dateEntered = new Date(input); console.log(input); //e.g. 2015-11-13 console.log(dateEntered); //e.g. Fri Nov 13 2015 00:00:00 GMT+0000 (GMT Standard Time) });
15th Mar 2018, 3:37 PM
Mike Choy
Mike Choy - avatar
0
Thanks Sir!
15th Mar 2018, 3:42 PM
Harshit Kumar
Harshit Kumar - avatar