Get the current time Codeigniter 3x?

1

I need to get the current time to insert it into the database, I have tried using the CI helper

$this->load->helper('date');

now();

I tried this function but it inserts me

00:00:00

Greetings thank you very much

    
asked by Javier Antonio Aguayo Aguilar 20.03.2017 в 06:52
source

2 answers

3

Try with:

date("Y-m-d H:i:s")

The date() function formats the current date / time.

More information about the possible formats that can be passed as a parameter in link

    
answered by 20.03.2017 в 14:23
1

most likely the error you have in the construction of the TABLE in MySQl, What is the data type of the field (DATE, TIME, TIMESTAMP ...)?

Try doing an echo of the variable with the CodeIgniter time to see where the problem is coming from.

Another option is to set the time in MySQL

date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

    
answered by 22.03.2017 в 17:15