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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
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.