Setting input[type=date] with Javascript
To save a lot of head scratching, if you need to programatically set a date input with Javascript you will need to pass the string as toISOString() and remove additional characters from the end using substring().
You may run into timezone issues, setting the Date.UTC object does the trick.
new Date(Date.UTC(this.currentYearView, this.currentMonthView, e.target.innerHTML)).toISOString().substring(0, 10);
Written by Ian Tearle
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Html
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#