Codeigniter显示按日,按周或每年分组

i have codeigniter framework, and i want to displaying my message data as group by daily, weekly, monthly or annually with this sample of UI:

Message= Yesterday:

  • text1
  • text2

Last week:

  • text3
  • text4
  • text5

Last Month: Last Years:

And for now, i done for just display normal style of message with this code controller

$total = count($this->query->get(
            "message",
                array("count"=>1, "order"=>$this->tableMessage.".msg_id desc", "group"=>$this->tableMessage.".msg_code", "where"=>array($this->tableMessage.".msg_from"=>getSessionUser(),$this->tableMessage.".msg_owner"=>getSessionUser()))
                )
            );                      
    $config['total_rows'] = $total;     
    $config['per_page'] = 8;
    $config['num_links'] = 3;
    $config['page_query_string'] = TRUE;
    $config['query_string_segment'] = 'page';


    $this->pagination->initialize($config);

    $data['pagination'] = $this->pagination->create_links();

    $offset = $this->input->get("page");

    if(empty($offset) || $offset == 0){
        $offset = 0;
    } 

    $data['subjectFor'] = "sent";
    $data['title'] = 'Sent';
    $data['message'] = $this->query->get(
            "message",
            array("limit"=>$config['per_page'], "offset"=>$offset, "order"=>$this->tableMessage.".msg_id desc", "group"=>$this->tableMessage.".msg_subject", "where"=>array($this->tableMessage.".msg_from"=>getSessionUser(),$this->tableMessage.".msg_owner"=>getSessionUser())),
            array("user"=>"msg_from")
        );              

    $this->load->view('user/message',$data);

But how can i display the message by group as i want?

Thankyou