Welcome Guest, Not a member yet? Register   Sign In
save current date and time in mysql with codeigniter
#1

[eluser]ranjitbd[/eluser]
function feedbackSave()
{
$data=array();

$data['name'] = $this->input->post('lname', true);
$data['email'] = $this->input->post('email', true);
$data['comments'] = $this->input->post('comments', true);

1. $date = date('Y-m-d');
2. $time = date('h:iConfused');
3. $dateTime = $date." ".$time;

4. $data['date'] = $dateTime;

$this->load->model($this->config->item('generalModel'), 'save_feedback',TRUE);
$this->save_feedback->feedbackSave($data);

$_SESSION['feedback'] = 'Feedback send successfully';
$this->feedback();
}

hi,
i have saved current date and time in mysql using line no 1,2,3,4. this is the way i used in php raw coding.
is there any convenient way or builtin function for doing this using codeigniter..
sorry for my poor english...
thanks in advance
#2

[eluser]Johan André[/eluser]
Sure... But why not:

Code:
$datetime = date('Y-m-d H:i:s');

Or make the database create a timestamp on create with todays date/time?

It also seems that you are setting a session at the end?
Is that for flash-messages?

Use the session-class instead:

Code:
$this->session->set_flashdata('feedback', 'Message');

...and you don't need to bother about clearing it manually afterwards.




Theme © iAndrew 2016 - Forum software by © MyBB