Home  >  Article  >  Backend Development  >  从mysql中提取time时候出现异常 来帮忙解决一上多谢

从mysql中提取time时候出现异常 来帮忙解决一上多谢

WBOY
WBOYOriginal
2016-06-13 10:38:15765browse

从mysql中提取time时候出现错误 来帮忙解决一下谢谢
正常时间显示的那个是在mysql正常的数据,能告诉我后面那个时间为什么会错吗?还有,我想用后面的格式来表达时间,应该怎么样?上码上图你就懂了,先谢过啦[

code=PHP


无标题文档





$mylink=mysql_connect("","root","");
mysql_select_db("test",$mylink);
$sql="select * from news";
$result=mysql_query($sql,$mylink);


while($row=mysql_fetch_array($result))
{
echo "正常时间:";
$abc=$row['time'];
echo $abc;

echo " 错误时间:";
echo date("y-m-d H:i:s",$abc);
echo "
"

;
echo "姓名:";
echo $row['name'];
echo "
";
echo "留言:";
echo $row['text'];
echo "
";
echo "
";
echo "
";
}
?>



[/code]


------解决方案--------------------
20120811203953
不是 unix 时间戳,需要这样
echo date('Y-m-d H:i:s', strtotime(20120811203953));

2012-08-11 20:39:53
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