php根据时间段分组,php按月分组(时间戳)
生活随笔
收集整理的这篇文章主要介绍了
php根据时间段分组,php按月分组(时间戳)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
用thinkphp做按日期年-月分组,发现日期是时间戳。日期型好操作些时间戳怎么搞?分离如下
使用mysql函数FROM_UNIXTIME(unix_timestamp,format)直接转换
select FROM_UNIXTIME(create_time,'%Y-%m') create_time from table;
按年-月分组实例$list = Db::name('order')->field('FROM_UNIXTIME(Date, "%Y-%m") as Date2')->group('Date2')->limit(0,10)->order('Date2 desc')->select()->toArray();
foreach ($list as $key => $value) {
$end = date("Y-m",strtotime($value['Date2'].'+1 month'));
echo$value['Date2'].'=='.$end.'==='.strtotime($end)."==
";
}
总结
以上是生活随笔为你收集整理的php根据时间段分组,php按月分组(时间戳)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 焕然白金卡算白金卡吗
- 下一篇: php try报错程序中断,php7异常