Home >Backend Development >PHP Tutorial > 怎么从数据库中获取格式化的datetime类型值

怎么从数据库中获取格式化的datetime类型值

WBOY
WBOYOriginal
2016-06-13 13:53:101374browse

如何从数据库中获取格式化的datetime类型值
mysql数据库的表中时间字段是datetime类型,用date()函数获得时间:$regtime=date( "Y-m-d   H:n:s ")。现在输出时需要只显示Y-m-d,如何格式化输出呢?

------解决方案--------------------
echo date( "Y-m-d ",strtotime($regtime));
为什么不保存为unix时间戳呢??

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