Can PHP assign the value of a drop-down list to a Date Type field in the database?

Source: Internet
Author: User
form part Code
Omit **************************************
Echo ' '; echo "Please select "; foreach ($year as $value) {echo '$value "; } Echo 'Years ';
Omit ********************************************************
?>
Form Validation Section Code
Omit ************************************************
if ($_post[' year ']!= Please select &&$_post[' month ']!= Please select &&$_post[' Day ']!= please select)
$birthday =$_post[' year '].$_post[' month '].$_post[' Day ';
else Array_push ($errors, ' Please choose a birthday date ');
if (!empty ($_post[' introduct ')) $introduction =$_post[' introduct '];
Omit *************************************************
?>
Now the problem is that I want to save the $birthday to the database data type field, but the value passed in is always 0000-00-00, unless I change the data type to character type, just learn PHP, please help us


Reply to discussion (solution)

Save with time stamp and change the type of time to int type. The time to deposit in is as follows

$date =stetotime ($birthday);

Save with time stamp and change the type of time to int type. The time to deposit in is as follows

$date =stetotime ($birthday);


$date =strtotime ($birthday);
Wrong call.

$birthday =$_post[' year ']. ' -'. $_post[' month '. ' -'. $_post[' Day ';

@xuzuning, the original can also be so, than 1 floor simple ah, however, your method is also very good @xxoome, thank you for your help!!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.