Fatal error: Call to a member function format() on a non-object in
View
<?php
$date = $listProject->enddate;
$data['enddate'] = $date->format('Y-m-d');
$time['time'] = $date->format('H:i:s');
?>
<?php echo get_datetime($listProject->enddate);?>(<?php echo '<b style="color:red;">'.days_left($listProject->enddate,$listProject->id).'</b>';?>)
Controller
$this->outputData['listProjects'] = $this->skills_model->getProjects($urgent_conditions,NULL,NULL,array(15),$order);
$this->load->view('listProjects',$this->outputData);
Model
$this->db->select('projects.created,projects.enddate');
Thank you! 😀
I tried to do it on VIew and controller but still getting error, the error above is caused by View
Add on Found this in MY_date_helper
if ( ! function_exists('get_datetime'))
{
function get_datetime($timestamp)
{
$CI =& get_instance();
$CI->lang->load('enduser/common');
if(date('d/M/Y') == date('d/M/Y',$timestamp))
$date = $CI->lang->line('Today at')." ".date('H:i',$timestamp)." UTC";
else
$date = date('d-M-Y H:i',$timestamp)." UTC";
return $date;
}
PHP Version : 5.2.17
Try
instead of
Edit: Make that: