Celcius Posted March 30, 2010 Share Posted March 30, 2010 I need a range of time to execute an sql query. I figured the best way to do this would be to select a single hour and then add and subtract from it on the other side into to variables. So here is my basic sending code: <form id="form3" name="form3" method="post" action="catchTime.php"> <label>Time <select name="time" id="time" class="location"> <option selected="selected"> </option> <option value="01:00">00:00 - 02:00</option> <option value="03:00">02:00 - 04:00</option> <option value="05:00">04:00 - 06:00</option> <option value="07:00">06:00 - 08:00</option> <option value="09:00">08:00 - 10:00</option> <option value="11:00">10:00 - 12:00</option> <option value="13:00">12:00 - 14:00</option> <option value="15:00">14:00 - 16:00</option> <option value="17:00">16:00 - 18:00</option> <option value="19:00">18:00 - 20:00</option> <option value="21:00">20:00 - 22:00</option> <option value="23:00">22:00 - 00:00</option> </select> </label> <br /> <input type="submit" class="submitBtn" value="Submit" /> </form> Then in the catchTime.php how can I create two values that can be executed as a range of time in a MySQL statement? Or is there a better way to do this? Link to comment https://forums.phpfreaks.com/topic/196944-addingsubtracting-from-a-time-variable/ Share on other sites More sharing options...
ram4nd Posted March 30, 2010 Share Posted March 30, 2010 if you use this method then i think its better to use numbers only a values. Like 1 instead of 01:00 Link to comment https://forums.phpfreaks.com/topic/196944-addingsubtracting-from-a-time-variable/#findComment-1033941 Share on other sites More sharing options...
Celcius Posted March 30, 2010 Author Share Posted March 30, 2010 if you use this method then i think its better to use numbers only a values. Like 1 instead of 01:00 That sounds good, now would can I turn say "13" into a time value that can be understood by MySQL so I can compare it? Link to comment https://forums.phpfreaks.com/topic/196944-addingsubtracting-from-a-time-variable/#findComment-1033953 Share on other sites More sharing options...
Celcius Posted March 30, 2010 Author Share Posted March 30, 2010 if you use this method then i think its better to use numbers only a values. Like 1 instead of 01:00 That sounds good, now how would I turn "13" into a time value that can be understood by MySQL so I can compare it? Trying to fix my awful English, sorry for the double post. Link to comment https://forums.phpfreaks.com/topic/196944-addingsubtracting-from-a-time-variable/#findComment-1033957 Share on other sites More sharing options...
ram4nd Posted March 30, 2010 Share Posted March 30, 2010 use date function's second parameter with strtotime maybe. I don't know exactly what you need to do. Link to comment https://forums.phpfreaks.com/topic/196944-addingsubtracting-from-a-time-variable/#findComment-1033993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.