I need to combine day, month and year in PHP in order to insert it to MySQL database. How I'll combine the day, the month and the year? I'm choosing the date from a drop down menu.
+1
A:
If the drop-downs have numeric values, you can just use ordinary date adding functions.
Rob Farley
2010-01-28 00:37:41
+2
A:
MySQL expects the date in this format: yyyy-mm-dd, so if you are using seprate drop downs for day, month and year you can cocatenate them like so:
$date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'];
If your form's method is 'get' instead of 'post', then substitute $_POST with $_GET in the code. Also make sure the value is set correctly for days 1 to 9 as 01 to 09 and you use a two digit value - the same for month. I.e.
<select name="month">
<option value="01">1</option>
...
</select>
Majid
2010-01-28 00:38:57