0
随着FQL我得到的生日以这种方式:如何保存Facebook的生日日期?
select uid, first_name, last_name, birthday_date from user where uid=me()
但随后这种格式显示:
02/03/1942
如果我将它保存在我的MySQL数据库的日期字段,它保存0000-00-00
如何在MySQL数据库中保存这个日期?
随着FQL我得到的生日以这种方式:如何保存Facebook的生日日期?
select uid, first_name, last_name, birthday_date from user where uid=me()
但随后这种格式显示:
02/03/1942
如果我将它保存在我的MySQL数据库的日期字段,它保存0000-00-00
如何在MySQL数据库中保存这个日期?
结帐这个OUT- http://php.net/manual/en/function.date-create.php
<?php
$test = new DateTime('02/31/2011');
echo date_format($test, 'Y-m-d H:i:s'); // 2011-03-03 00:00:00
$test = new DateTime('06/31/2011');
echo date_format($test, 'Y-m-d H:i:s'); // 2011-07-01 00:00:00
?>
可以养活DateTime()
构造一个字符串,它是类似于Facebook的回报,然后使用该对象来格式化您需要的日期格式。
另外,如果你想只包含的MYSQL解决方案的选项,你可以简单地通过STR_TO_DATE
传递原始日期和喂养它的当前格式。这将以正确的方式为DATE
字段类型格式化日期。
INSERT INTO `test` ( `date`)
VALUES (
STR_TO_DATE( '02/03/1942', '%d/%m/%Y')
)
查看the documentation of STR_TO_DATE()了解更多详情。