About DEFAULT CURRENT_TIMESTAMP!

2

Good afternoon everyone again, Guys now I'm fighting with default insert the date in a table of my mySql. Table Appointment. Of course, the client does not have to enter the date, but I am interested in knowing when the appointment request was entered.

Thank you!

    
asked by Akyna 02.06.2016 в 21:25
source

2 answers

3

If you have made a query to create your table, you can create the field in this way in mySql:

 create table Cita(campotimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

This way you will have the current timestamp as default.

For more details you can check the documentation:

Automatic initialization and update for TIMESTAMP and DATETIME. (English).

    
answered by 02.06.2016 / 22:19
source
1

With this:

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

$query = "INSERT INTO usuario (...,...,fecha...)....VALUES  ('".$fecha_registro."',....)

Just add another field to your bd and in the insert in your PHP add the date. In MySQL the type would be datetime

    
answered by 02.06.2016 в 21:40