把mysql中时间戳转化成正常时间, 用mysql函数: from_unixtime(数据库time字段,“%Y%m%d”);
例如,按月统计:
1
select
count
(id), from_unixtime(select_time,
'
%Y-%m
'
)
as
result, from_unixtime(select_time,
'
%Y
'
)
as
year
, from_unixtime(select_time,
'
%m
'
)
as
month
2
from
diray
3
group
by
year
,
month
4
order
by
year
desc
,
month
desc
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)