我有下一个代码:
//$item['Update']="2015-02-16 16:03:13"; value from debug,from mysql
date("Y-m-d", strtotime($item['Update']));
为什么它会回归1970-01-01?
问题已解决,来自mysql的数据为空。
答案 0 :(得分:1)
[[!get_childrens_count:gt=`0`:then=`toto`:else=`titi`]]
同时检查一下(以MySQL的方式完成。)
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_unix-timestamp
更新:
echo date("Y-m-d", strtotime($item['Update']));
两个陈述的输出:
$item['Update'] = '2015-02-16 16:03:13';
$date = new DateTime($item['Update']);
echo $date->format('Y-m-d'); // 2015-02-16
答案 1 :(得分:0)
使用单引号而不是双引号
DoSomething
答案 2 :(得分:0)
由于您并没有真正转换日期格式而只是剥离时间,因此使用substr
<?php
$item['Update']="2015-02-16 16:03:13";
echo substr($item['Update'],0,10);
?>