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

Source: Internet
Author: User
Can PHP assign the value of the drop-down list to a date field in the database? part of the form code
**************************************** ******************************* *******
Echo' ';Echo"Select";Foreach ($ year as $ value ){Echo"$ Value";}Echo'Year ';
******** **************************************** ********
?>
Code for form verification
**************************************** ************************************* Is omitted *************************************** *********
If ($ _ POST ['Year']! = Select & $ _ POST ['month']! = Select & $ _ POST ['day']! = Select)
$ Birthday = $ _ POST ['Year']. $ _ POST ['month']. $ _ POST ['day'];
Else array_push ($ errors, 'select the birthdate ');
If (! Empty ($ _ POST ['initduct ']) $ introduction = $ _ POST ['initduct'];
**************************************** ************************************ *************
?>
The problem now is that I want to save $ birthday to the database data type field, but the value passed in is always 0000-00-00, unless I change the data type to bytes, I just learned PHP. please help me.


Reply to discussion (solution)

Save it with a timestamp and change the time type to the int type. When saving the data as follows:

$date=stetotime($birthday);

Save it with a timestamp and change the time type to the int type. When saving the data as follows:

$date=stetotime($birthday);


$date=strtotime($birthday);
Error.

$ Birthday = $ _ POST ['Year']. '-'. $ _ POST ['month']. '-'. $ _ POST ['day'];

@ Xuzuning: it turns out this way. it's easier than the first floor. However, your method is also quite 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.