首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >tp5查询时将时间戳直接转为年月日类型

tp5查询时将时间戳直接转为年月日类型

作者头像
超级小可爱
发布于 2023-02-20 17:18:00
发布于 2023-02-20 17:18:00
1.5K0
举报
文章被收录于专栏:小孟开发笔记小孟开发笔记

写法   FROM_UNIXTIME(daytime,”%H:%i) as daytime

​

示例如下:

代码语言:javascript
复制
/************设备流量图*********************/
public function device_flow_map(){
$deviceId=$this->request->param('deviceId');
$date=$this->request->param('date','today');
$one=Db::name('device_lists')->where('deviceId',$deviceId)->field('id,deviceId,description,deviceIconType,statusEnum')->find();
if(!$one){
$this->error('该设备不存在');
}
$arr['upload_list']=Db::name('device_band')->where('deviceId',$deviceId)->whereTime('daytime',$date)->where('type','upload')->field('id,deviceId,bandWidth,FROM_UNIXTIME(daytime,"%H:%i") as daytime')->select();
$arr['download_list']=Db::name('device_band')->where('deviceId',$deviceId)->whereTime('daytime',$date)->where('type','download')->field('id,deviceId,bandWidth,FROM_UNIXTIME(daytime,"%H:%i") as daytime')->select();
$this->success('成功',$arr);

}

这里把 daytime格式化了,只保留小时和分钟部分

未经允许不得转载:肥猫博客 » tp5查询时将时间戳直接转为年月日类型

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档