Home > Backend Development > PHP Tutorial > 怎样把时间戳转换成其它格式

怎样把时间戳转换成其它格式

WBOY
Release: 2016-06-23 13:33:13
Original
1065 people have browsed it


$conn = mysql_connect("localhost","root","qqaazz");
mysql_select_db("2",$conn); 
mysql_query("SET NAMES GBK"); 
$sql = "SELECT * FROM `yang_user` WHERE `fullname` = 'qqaazz'";
$result=mysql_query($sql,$conn); 
while($row=mysql_fetch_assoc($result))
{
echo"

".$row["uid"]." ".$row["uname"]." ".$row["utype"]." ".$row["email"]." ".$row["regtime"]." ";
}
 
?>
这段代码获得的regtime是1433490427这种形式,怎样转换成2015-05-25 14:53:11这种形式?


回复讨论(解决方案)

echo date('Y-m-d H:i:s', 1433490427); //2015-06-05 15:47:07

echo date('Y-m-d H:i:s', 1433490427); //2015-06-05 15:47:07

获取的regtime是变量,不是固定值1433490427,这样不行

醉了醉了,你把regtime变量填进去不就行了么.....echo date('Y-m-d H:i:s', $regtime);
版主是给你示范呢

详情请查看php手册中的date()函数

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template