My friend and I are doing a school project; the task is to make a room-reservation-site. This is our first year trying JavaScript, and we want a string to be formatted into time (h:m). The user of our room-reservation-site can choose what time of the day he/she wants the room, and the output is: H:m (24hour-clock:minutes). For example 12:15.
Therefor my question is: Is there possible to convert this string (h:m) into time, and easily check if the user typed more than 30minutes of booking-time? So we can for example say:
if(start_of_reservation < start_of_reservation(+30minutes)){
alert("You need to book a room atleast 30minutes"); }
else if(start_of_reservation > start_of_reservation(+6hours)){
alert("You can't book a room longer than 6 hours"); }
else {
// moving on..
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With