I am trying to insert current datetime to oracle database in codeigniter but getting error as follows:
ORA-01858: a non-numeric character was found where a numeric was expected
INSERT INTO "USER_LOGS" ("USER_ID", "IP_ADDRESS", "LOGIN_DATE", "LOG_TYPE", "USERNAME") VALUES ('1', '::1', 'TO_DATE(''2018-07-17 03:33:03'',''yyyy/mm/dd hh24:mi:ss'')', 'LOG OUT', 'admin')
My Code:
date_default_timezone_set("Asia/Dhaka");
$timestamp = date('Y-m-d h:i:s');
$timestamp = "TO_DATE('$timestamp','yyyy/mm/dd hh24:mi:ss')";
$user_log_data = array(
'USER_ID' => $ses_data['USER_ID'],
'IP_ADDRESS' => $this->input->ip_address(),
'LOGIN_DATE' => $timestamp,
'LOG_TYPE' => 'LOG OUT',
'USERNAME' => $ses_data['USERNAME']
);
$this->utilities->insertData($user_log_data, 'USER_LOGS');
My Insert Statement:
function insertData($post, $tableName)
{
$this->db->trans_start();
$this->db->insert($tableName, $post);
$this->db->trans_complete();
if ($this->db->trans_status() == TRUE) {
return TRUE;
} else {
return FALSE;
}
}
For your kind information, the data type of the field (LOGIN_DATE) is TIMESTAMP
Thanks