Jump to content

Getting The Current Date And Time In Codeigniter


booxvid

Recommended Posts

 public function create_blog(){

$this->load->view('header');
$this->form_validation->set_rules('blogtitle','Blog Title','required');
$this->form_validation->set_rules('desc','Description','required');

$this->form_validation->set_error_delimiters('
','');

if($this->form_validation->run()==FALSE){
$this->load->view('view_dashboard_addblog');
}
else{
$title =$this->input->post('blogtitle');
$desc = $this->input->post('desc');


$data = array(
'blog_title'=>$title,
'description'=>$desc,
'blog_date'=>CURDATE(),
'blog_time'=>CURTIME());


$this->blog_model->insert_posts($data);
echo "";
$this->load->view('view_blog');
}

}

 

My problem is, curdate() and curtime() function for mysql doesn't work at all,

it says an undefined function, how to get the current date and time in Codeigniter and insert it into my mysql table

Link to post
Share on other sites
  • 2 weeks later...

if you use active records, then adding the date should look something like this:

 

$this->db->set('created', 'NOW()', FALSE)->insert('posts', $data);

 

where table field created is mysql datetime. $data does not contain created at all.

Link to post
Share on other sites
  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.