我希望用户选择一天中的某个时间,然后我想使用该date()
函数进行转换,以便将其插入 Mysql 数据库datetime
表字段中。
<select name="event-start-time-hours" class="event-time">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8" selected>8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select name="event-start-time-mins" class="event-time">
<option value="00" selected >00</option>
<option value="05">05</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
<option value="55">55</option>
</select>
<select name="event-start-timeofday" class="event-time">
<option value="" selected >AM</option>
<option value="">PM</option>
</select>
我试过了:
$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']);
返回:
字符串(8)“01:03:22”220
那么如何正确格式化呢?非常感谢。