How to save the date in a table in mysql

0

I'm trying to insert the current date into a table, I'm using the following code:

insert into testar (data,nome) VALUES (date("Y-m-d H:i:s"),'pedro');

But the error:

  

Column 'data' can not be null.

    
asked by anonymous 03.07.2017 / 00:02

3 answers

1

Make use of CURRENT_TIMESTAMP

INSERT INTO testar (data,nome) VALUES (CURRENT_TIMESTAMP,'pedro')
    
03.07.2017 / 00:41
0

Use NOW () to put the current date.

INSERT INTO testar 
(data, nome)
VALUES 
(NOW(), 'Pedro')
    
03.07.2017 / 00:07
0

You can use the NOW () command so it would look like this:

insert into testar (data,nome) VALUES (NOW(),'pedro');
    
03.07.2017 / 00:07