Alan Alan - 1 year ago 89
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:


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){
... }

So how do i do it?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download