How can I format input fields to form time of day using PHP date() function? <p>I want the user to select a time of day which I then want to convert using the <code>date()</code> function so it can be inserted into a Mysql database <code>datetime</code> table field.</p> <pre><code>&lt;select name="event-start-time-hours" class="event-time"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;option value="7"&gt;7&lt;/option&gt; &lt;option value="8" selected&gt;8&lt;/option&gt; &lt;option value="9"&gt;9&lt;/option&gt; &lt;option value="10"&gt;10&lt;/option&gt; &lt;option value="11"&gt;11&lt;/option&gt; &lt;option value="12"&gt;12&lt;/option&gt; &lt;/select&gt; &lt;select name="event-start-time-mins" class="event-time"&gt; &lt;option value="00" selected &gt;00&lt;/option&gt; &lt;option value="05"&gt;05&lt;/option&gt; &lt;option value="10"&gt;10&lt;/option&gt; &lt;option value="15"&gt;15&lt;/option&gt; &lt;option value="20"&gt;20&lt;/option&gt; &lt;option value="25"&gt;25&lt;/option&gt; &lt;option value="30"&gt;30&lt;/option&gt; &lt;option value="35"&gt;35&lt;/option&gt; &lt;option value="40"&gt;40&lt;/option&gt; &lt;option value="45"&gt;45&lt;/option&gt; &lt;option value="50"&gt;50&lt;/option&gt; &lt;option value="55"&gt;55&lt;/option&gt; &lt;/select&gt; &lt;select name="event-start-timeofday" class="event-time"&gt; &lt;option value="" selected &gt;AM&lt;/option&gt; &lt;option value=""&gt;PM&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I tried:</p> <pre><code> $time = $_POST['event-start-time-mins'] .$_POST['event-start-time-hours']; var_dump($dob = date("H:i:s", $time)); print_r($_POST['event-start-time-hours']); print_r($_POST['event-start-time-mins']); </code></pre> <p>Which returns:</p> <blockquote> <p>string(8) "01:03:22" 220</p> </blockquote> <p>So how do I format this correctly? Many thanks.</p>