Home > Backend Development > PHP Tutorial > 初学有关问题 hp中的date()

初学有关问题 hp中的date()

WBOY
Release: 2016-06-13 10:10:38
Original
814 people have browsed it

初学问题 hp中的date()
mysql 一字段是 datetime类型 存入的值2012-02-23 09:24:40

为什么用date('Y-m-d',日期字段) 得到的是1970-011

如何才能得到2012-02-23

------解决方案--------------------
select date_format(日期字段,"%Y-%m-%d") from 表名
------解决方案--------------------
用mysql的函数处理即可。php的date日期字段是个整数时间戳
------解决方案--------------------
传递的参数应该是 int $timestamp 时间戳

echo date('Y-m-d',strtotime('now'));

或者直接

echo date('Y-m-d');

如果你要得到你在mysql里的时间可以转换成时间戳后再转换

date('Y-m-d',strtotime(日期字段));

Related labels:
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