I am using the following code at this codepen to try to populate a datetime-local
input element with today's data and time. What they have on this tutorial does not work. I also tried what is in this SO post but also does not seem to work. How do can I set the datetime to today's date and time into a datetime-local
input element. Thank you.
HTML:
<input type="datetime-local" id="datetime" name="datetime">
JS:
let today = new Date().toISOString();
document.getElementById('datetime').value = today;
console.log(today);