Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将日期保存到MySQL_Php_Mysql - Fatal编程技术网

Php 将日期保存到MySQL

Php 将日期保存到MySQL,php,mysql,Php,Mysql,我在将日期保存到MySQL数据库时遇到了这个问题 我有一个输入字段: <input type="date" name="theDate" id="theDate" required></p> 数据库字段是日期,但它只保存0000-00-00 当我在保存日期之前回显日期时,它是正确的2012-02-23 我希望任何人都能告诉我这是怎么做到的 date('Y.m.d', strtotime($table['day'])); 输出2012.02.23非2012-02-23。

我在将日期保存到MySQL数据库时遇到了这个问题

我有一个输入字段:

<input type="date" name="theDate" id="theDate" required></p>
数据库字段是日期,但它只保存
0000-00-00

当我在保存日期之前回显日期时,它是正确的
2012-02-23

我希望任何人都能告诉我这是怎么做到的

date('Y.m.d', strtotime($table['day']));
输出
2012.02.23
2012-02-23
。。。你需要

date('Y-m-d', strtotime($table['day']));

很简单,MySQL希望输入为
Y-m-d
。使用它而不是
Y.m.d
。谢谢你们两位。有时正确的答案就在你面前,但你需要有人指出它。。。(我现在很惭愧)
date('Y-m-d', strtotime($table['day']));