Alan Alan - 4 months ago 8
Javascript Question

How to convert String h:m to hour format?

So I have a JSON object that looks like this,

{"active": "1", "opening": "11:00", "closure": "20:00"}


and a user input that is a String that is current time in h:m format, example:

17:54


How can I convert user's input to hour time and compare it against opening and closure. I want to do

if(closure > input && input > opening){
... }
else{
...}


So how do i do it?

Answer

Time in the hh:mi format is comparable as-is.

Comments