致命错误:在非对象上调用成员函数 format()
看法
<?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>';?>)
控制器
$this->outputData['listProjects'] = $this->skills_model->getProjects($urgent_conditions,NULL,NULL,array(15),$order);
$this->load->view('listProjects',$this->outputData);
模型
$this->db->select('projects.created,projects.enddate');
谢谢!:D 我尝试在 VIew 和控制器上执行此操作,但仍然出现错误,上面的错误是由 View 引起的
添加在 MY_date_helper 中找到这个
if ( ! function_exists('get_datetime'))
{ 函数 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版本:5.2.17