(06-21-2016, 09:46 PM)pravins Wrote: If you are explicitly want to add date in table then you can use below code
PHP Code:
$this->db->set('content_date', 'NOW()', FALSE);
or
$data['content_date'] = date('Y-m-d H:i:s');
and if you want to add date automatically when article is inserted, then you need to set default value of date field as CURRENT_TIMESTAMP and its data type should be timestamp
hope this will help you
This is good. But what if I only want to type the date without timestamp. Can anyone help me?
Pages_model.php
PHP Code:
public function insert_pages()
{
$data = array(
'pages_name' => $this->input->post('pages_name'),
'create_date' => date('Y-m-d'),
'pages_order' => $this->input->post('pages_order'),
'pages_content' => $this->input->post('pages_content')
);
return $this->db->insert('pages', $data);
}
and I get this new error message:
Thank you for filling the information. It has been successful.
Pages Name: Home
Create Date:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: create_date
Filename: views/submitpages.php
Line Number: 45
Backtrace:
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\views\submitpages.php
Line: 45
Function: _error_handler
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php
Line: 107
Function: view
File: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\index.php
Line: 315
Function: require_once
Order: 2
" If I looks more intelligence please increase my reputation."