in model
$this->db->select('message,timestampdiff(minute,date_added,current_timestamp) minutes_passed'); $this->db->from('activity_logs'); $this->db->order_by('log_id','desc'); $this->db->limit(20); $q = $this->db->get(); return $q->result_array();
in controller
$data['logs'] = $this->common_model->get_logs(); foreach ($data['logs'] $k) { echo 'total minutes'.$k['minutes_passed']."<br>";//output total minutes "21410" }
i have total number of minutes , want total hours related minutes , hours convert total days. hope can guide me through this. thanks.
try function,
& modify requirements
function con_min_days($mins) { $hours = str_pad(floor($mins /60),2,"0",str_pad_left); $mins = str_pad($mins %60,2,"0",str_pad_left); if((int)$hours > 24){ $days = str_pad(floor($hours /24),2,"0",str_pad_left); $hours = str_pad($hours %24,2,"0",str_pad_left); } if(isset($days)) { $days = $days." day[s] ";} return $days.$hours." hour[s] ".$mins." min[s]"; }
Comments
Post a Comment