Home  >  Article  >  Backend Development  >  PHP能将下拉列表的值赋给数据库中date类型的字段吗解决方案

PHP能将下拉列表的值赋给数据库中date类型的字段吗解决方案

WBOY
WBOYOriginal
2016-06-13 12:04:44955browse

PHP能将下拉列表的值赋给数据库中date类型的字段吗
表单部分代码
************************************************省略**************************************
echo '年';
*******************************省略********************************************************
?>
表单验证部分代码
****************************************省略************************************************
if($_POST['year']!=请选择&&$_POST['month']!=请选择&&$_POST['day']!=请选择)
$birthday=$_POST['year'].$_POST['month'].$_POST['day'];
else array_push($errors,'请选择生日日期');
if(!empty($_POST['introduct'])) $introduction=$_POST['introduct'];
*******************************************省略*************************************************
?>
现在的问题是,我想将$birthday存到数据库data类型的字段下,可是传进去的值一直是0000-00-00,除非我把data类型换成字符型,刚学PHP,请大家帮忙啊
------解决方案--------------------
用时间戳保存,把时间类型改成int型吧。存进去的时候如下

$date=stetotime($birthday);

------解决方案--------------------

引用:
用时间戳保存,把时间类型改成int型吧。存进去的时候如下
$date=stetotime($birthday);

$date=strtotime($birthday);
打错。
------解决方案--------------------
$birthday=$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn