DATE_FORMAT怎么用

WBOY
Release: 2016-06-23 13:46:07
Original
975 people have browsed it

DATE_FORMAT(submit_time,'%Y年%m月%d日%H时%i分%s秒');
按上面做年月日都出来了,时分秒没出来一直是00时00分00秒
怎么回事


回复讨论(解决方案)

你的 submit_time 字段有时分秒吗

我直接写的NOW(),这个不行吗

你的 submit_time 字段有时分秒吗


我直接写的NOW(),这个不行吗

可以的啊。。

你数据库里有时分秒吗? 类型是date 还是 datetime ?

可以的啊。。


 $sql="select id,username,sex,qq,email,info,ip,DATE_FORMAT(submit_time,'%Y年%m月%d日%H时%i分%s秒') from lo order by id desc limit $offset,$pagesize";
这个是代码,有错吗?

你数据库里有时分秒吗? 类型是date 还是 datetime ?


好像是date

那不就对了 ,date 后面没有时分秒 

select DATE_FORMAT(addtime,'%Y-%m-%d') as time,count(*) as countes from `表名`  group by time

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!