[eluser]Stenson[/eluser]
I am trying to find a way to show the 'Age' of the row stored within the Pagination. For example instead of showing the timestamp as the date/time, I want to show it as 'Posted 10 minutes ago', '2 days ago' etc..
My problem is that my data is displayed using the 'foreach' statement which echos '$row->lectureCreated' but this needs to be changed somehow.
How would i go about doing this? Sorry if this still seems very unclear...
My function within the Controller is this:-
Code:
function admin_viewlectures() {
if($this->session->userdata('admin_is_logged_in') != TRUE) {
redirect('login/index');
} else {
$this->load->library('pagination');
$config['base_url'] = 'http://localhost:8888/****/index.php/site/admin_viewlectures/';
$config['total_rows'] = $this->db->count_all('lectures');
$config['per_page'] = '12';
$this->pagination->initialize($config);
$data['pagination_links'] = $this->pagination->create_links();
$this->load->model('lecture_model');
$data['lecture_query'] = $this->lecture_model->read($config['per_page'], $this->uri->segment(3));
$this->load->view('admin/viewlectures', $data);
}
}
View
Code:
<?php if(isset($lecture_query)) : foreach($lecture_query->result() as $row) : ?>
<li>
<div class="leftarea"> <!-- Left Area Start -->
<div class="posttitle"><?php echo $row->lectureTitle; ?></div>
<div class="course"><?php echo $row->courseID; ?></div>
<div class="module"><?php echo $row->moduleID; ?></div>
<div class="created"><?php echo $row->lectureCreated; ?></div>
</div> <!-- Left Area End -->
<div class="rightarea"> <!-- Right Area Start -->
<div class="listoptions">
<?php echo anchor("lecture/editLecture/$row->lectureID", '<span class="hide">Edit</span>',
'class="editbutton" title="Edit ' . $row->lectureTitle . '"'); ?>
<?php echo anchor("lecture/deleteLecture/$row->lectureID", '<span class="hide">Remove</span>',
'class="removebutton" title="Delete ' . $row->lectureTitle . '"'); ?>
</div>
</div>
</li>
<?php endforeach; ?>
<?php else : ?>
<h2>No records were returned.</h2>
<?php endif; ?>