Jump to content

Adding/Subtracting from a time variable


Celcius

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.