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

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

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

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'];
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn