Php 如何组合从下拉列表中选择的日期/时间以用于MySQL查询?

Php 如何组合从下拉列表中选择的日期/时间以用于MySQL查询?,php,mysql,arrays,date,drop-down-menu,Php,Mysql,Arrays,Date,Drop Down Menu,我有两组四个下拉列表——startDate、startMonth、startYear、startTime(as 24.00)和endDate/Time,供用户选择开始日期/时间和结束日期/时间,但不知道如何将所选值转换为datetime格式,以便在使用javascript或最好是php(5)的记录集查询中使用 我知道我需要将所选数据组合到阵列中,例如: //start and end Date/Time arrays from dropdowns - year,month,day and tim

我有两组四个下拉列表——startDate、startMonth、startYear、startTime(as 24.00)和endDate/Time,供用户选择开始日期/时间和结束日期/时间,但不知道如何将所选值转换为datetime格式,以便在使用javascript或最好是php(5)的记录集查询中使用

我知道我需要将所选数据组合到阵列中,例如:

//start and end Date/Time arrays from dropdowns - year,month,day and time without seconds 
$startDT=$sYear.$sMonth.$sDay.' '.$sTime.':00';
$endDT =$eYear.$eMonth.$eDay.' '$eTime.':00';
但是我在哪里以及如何使用它们,以便在MySQL查询中使用它们,例如:

SELECT *
FROM availability
BETWEEN '%startDT%' AND '%endDT%'
答案可能很简单,但在经历了大量的挠头、拉扯头发和过量的咖啡因之后,我就是想不出来……这就是金发时刻!
我希望有人能帮助这个有自杀倾向的php新手。

将您的数据组合成一个字符串,并使用它将其转换为unixtime。然后将unixtime数据保存到数据库中。

但我不想在数据库中保存时间,我只想用它来查询数据库……我在数据库中使用datetime 0000-00-00:00:00