views:

161

answers:

1

I've got two sets of four dropdowns - startDate,startMonth,startYear,startTime (as 24.00) and the same for endDate/Time - for user to select a start date/time and an end date/time, but don't know how to get the selected values into a datetime format to use in a recordset query using javascript or preferably php(5).

I know I need to combine the selected into arrays such as:

//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';

but where and how do I use these so I can use them in a MySQL a query such as:

SELECT *
FROM availability
BETWEEN '%startDT%' AND '%endDT%'

The answer is probably very simple but after a lot of head scratching, hair pulling and excessive caffeine I just can't work it out...call it a blond moment! I hope someone can help this suicidal newbie to php.

+2  A: 

Combine your data into a string and use strtotime() to convert that to unixtime. Then save that unixtime data into your database.

Ólafur Waage
But I don't want to save the time in the database, I just want to use it to QUERY the database ...and I'm using datetime 0000-00-00 00:00:00 in the db
Brainache