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数据库处理封装类实例

本文实例讲述了PHP数据库处理封装类。分享给大家供大家参考,具体如下: MySQL的操作相关类,检查并使用了mysqli <?php //sampl...

再推荐十款免费的php开发工具

再推荐十款免费的php开发工具

下面介绍10个免费、强大的PHP编辑器/开发工具。这些编辑器拥有调试器、增量执行PHP脚本、查看每一行的所有变量值等功能。 1) Notepad ++   Notepad++是一款非常有...

PHP简单实现合并2个数字键数组值的方法

本文实例讲述了PHP简单实现合并2个数字键数组值的方法。分享给大家供大家参考,具体如下: 先要了解一个基础知识点:PHP合并数组+与array_merge的区别分析 <?...

php strrpos()与strripos()函数

strripos() 函数 定义和用法strripos() 函数查找字符串在另一个字符串中最后一次出现的位置。如果成功,则返回位置,否则返回 false。 语法strrpos(strin...

php实现约瑟夫问题的方法小结

本文实例总结了php实现约瑟夫问题的方法。分享给大家供大家参考。具体分析如下: 一群猴子排成一圈,按1,2,...,n依次编号。然后从第1只开始数,数到第m只,把它踢出圈,从它后面再开始...