I have a countup app. Here is the thing: https://stackblitz.com/edit/web-platform-mjepwa?file=main.js]
I have this code in my function. It sets from when the timer starts counting.
past = Date.parse('2023-02-8 02:20:00');
I want to set the timer with "type="datetime-local" input.
I have no idea how to do it. Thanks in advance!
Date.parse(<date>)to use whatever the value of the input is. For example:var elem = document.querySelector("input.time-input"); var tm = elem.value; if(!tm) { tm = new Date(); tm = tm.toISOString(); }Is that what you had in mind?!tmtest fails, then tm is a string andtm.toISOString()will throw an error. Hence answers should be as answers, not in comments.var tm = ""; if(!tm) { tm = new Date(); tm = tm.toISOString(); console.log(tm); }is showing what it's supposed to show:2023-02-13T19:33:14.452Zat the time of posting this comment.