I am trying to figure out solution to fix the issue of not allowing user to select previous time. I mean for eg
Today's date: 17-02-2019
Current Time: 02:30 PM
So when user selects today's date and selects the time 02:30 AM instead of PM. Here the time is past so user shouldn’t be allowed to select the AM time because the current time is 02:30 PM
As per MDN docs the below code should work but it’s not working.
<input type="datetime-local" min="2019-02-17T14:30" />
As per below docs it shouldn’t allow me to select time like eg 9:00 AM, 10:00 AM even 02:29 PM but I am allowed to select. I even tried their fiddle example but their examples do allow me to select past time
I am trying to figure out solution to fix the issue of not allowing user to select previous time. I mean for eg
Today's date: 17-02-2019
Current Time: 02:30 PM
So when user selects today's date and selects the time 02:30 AM instead of PM. Here the time is past so user shouldn’t be allowed to select the AM time because the current time is 02:30 PM
As per MDN docs the below code should work but it’s not working.
<input type="datetime-local" min="2019-02-17T14:30" />
As per below docs it shouldn’t allow me to select time like eg 9:00 AM, 10:00 AM even 02:29 PM but I am allowed to select. I even tried their fiddle example but their examples do allow me to select past time
https://developer.mozilla/en-US/docs/Web/HTML/Element/input/datetime-local
Share Improve this question edited Feb 22, 2019 at 13:24 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Feb 17, 2019 at 10:30 Hemadri DasariHemadri Dasari 34k40 gold badges124 silver badges166 bronze badges1 Answer
Reset to default 5This may be because of the format , you may need to strip off the seconds. In console.log you can see the seconds but when setting the min
value the seconds and microseconds need to strip off
var today = new Date().toISOString();
console.log(today)
document.getElementById("daTi").min = '2019-02-17T10:38';
<input type="datetime-local" id='daTi' />