写法 FROM_UNIXTIME(daytime,”%H:%i) as daytime
示例如下:
/************设备流量图*********************/ 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查询时将时间戳直接转为年月日类型