PHP articles are archived by date of month day SQL statement

  • 2020-05-26 08:04:49
  • OfStack

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

PHP articles are filed by date (day) SQL
 
select FROM_UNIXTIME(pubtime, '%Y-%m-%d') as pubtime, count(*) as cnt from articles group by FROM_UNIXTIME(pubtime, '%Y-%m-%d') 

Non-timestamp date format archive (date_format format date)
 
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  month  %d  day ') 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 

Related articles: