[eluser]maverickmind[/eluser]
Apologies for the noob question. I've been using CodeIgniter and PHP for only a few weeks now. I attempted to find an answer to my question searching the forums. But after going through 9 pages of posts I'm hoping someone can point me in the right direction.
Basically I'm trying to figure out how to modify the result_array before I pass it back to my view. I need to parse a DateTime field into Data and Time before it gets displayed in the view.
I'm trying to turn this:[DateTime] => 2009-09-07 09:00:03
into this [Date] => 08/07/09 [Time] => 10:00 am
When I dump the contents of my $data variable the "Date", "Time" keys aren't in the array. It is driving me crazy. Any and all help would be greatly appreciated.
In the model I do this.
Code:
function GetTestMemos($TestID, $ProfileID)
{
$this->db->where('TestID', $TestID);
$this->db->where('ProfileID', $ProfileID);
$this->db->order_by('DateTime', 'desc');
$query = $this->db->get('TestMemos');
if($query->num_rows() > 0)
{
return $query->result_array() ;
}
Then I do this in my controller
Code:
$data['test'] = $this->dashboard_model->GetTestData( $this->session->userdata('TestID'), $this->session->userdata('ProfileID'));
foreach ($data['tests'] as $test)
{
$dT = explode(" ", $test['DateTime']);
$tempdate = $dT[0];
$time = $dT[1];
$test['Date'] = date("m/d/y", strtotime($tempdate));
$test['Time'] = date("g:i a", strtotime($time));
}
$this->load->view('/layout/header');
$this->load->view('/dash/confirm', $data);
$this->load->view('/layout/footer');
When I dump the contents of my $data variable the "Date", "Time" keys aren't in the array. It is driving me crazy. Any and all help would be greatly appreciated.
Hopefully this made sense if not please let me know what I need to provide.
Thanks in advance!