找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1341|回复: 0
打印 上一主题 下一主题

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

[复制链接]

2487

主题

2487

帖子

7391

积分

论坛元老

Rank: 8Rank: 8

积分
7391
跳转到指定楼层
楼主
发表于 2018-2-14 08:26:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            [U]复制代码[/U] 代码如下:
select FROM_UNIXTIME(pubtime, '%Y-%m') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m')

PHP文章按日期(日)SQL归档
[U]复制代码[/U] 代码如下:
select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d')

非时间戳日期格式归档(date_format格式化日期)
[U]复制代码[/U] 代码如下:
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日期比较方法
  • PHP笔记之:日期函数的使用介绍
  • 解析php时间戳与日期的转换
  • PHP函数之日期时间函数date()使用详解
  • php格式化日期和时间格式化示例分享
  • PHP输出英文时间日期的安全方法(RFC 1123格式)
  • php计算两个日期时间差(返回年、月、日)
  • PHP计算一年多少个星期和每周的开始和结束日期
  • PHP中的日期加减方法示例
  • php格式化日期实例分析
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端