PHP文章按日期(月日)SQL归档语句

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')

PHP文章按日期(日)SQL归档
复制代码 代码如下:

select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')

非时间戳日期格式归档(date_format格式化日期)
复制代码 代码如下:

select date_format(`post_date`,'%Y%m%d') as pubtime, count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc
select date_format(`post_date`,'%Y%m%d') as pubtime,date_format(`post_date`,'%m 月 %d 日') as shijian,count(*) as cnt from wp_posts where `post_status`='publish' group by date_format(`post_date`,'%Y%m%d') order by `ID` desc limit 0,7

相关文章

PHP将DateTime对象转化为友好时间显示的实现代码

复制代码 代码如下: /** * 友好日期时间 * * @param DateTime $datetime 日期时间 * @param int $size 精确到位数 * @throws...

PHP实现获取并生成数据库字典的方法

PHP实现获取并生成数据库字典的方法

本文实例讲述了PHP实现获取并生成数据库字典的方法。分享给大家供大家参考,具体如下: <?php /** * 生成mysql数据字典 */ header("Con...

php5.2 Json不能正确处理中文、GB编码的解决方法

php5.2新增的json功能是非常受欢迎的,但是经过测试发现, json_encode对中文的处理是有问题的, 1.不能处理GB编码,所有的GB编码都会替换成空字符. 2.utf8编码...

PHP时间类完整实例(非常实用)

本文实例讲述了PHP时间类。分享给大家供大家参考,具体如下: <?php header("Content-type:text/html;Charset=utf-8");...

php HTML无刷新提交表单

通常对于无刷新提交表单,我们都是运用ajax实现的。前段时间跟着老大了解到另一种无刷新提交表单的方法,是利用iframe框架实现的。现在整理出来分享给大家。 第一种: html页面...