Format date in INSERT and UPDATE Mysql PHP

3

Well, I have a data grid with a date, but I have to use a JQuery mask :

$(document).ready(function(){
    $('.date').mask('00.00.0000');  
});

But when I make an INSERT, for example, the date 19.11.2016 becomes 21.11.2019. This same case happens with UPDATE.

In the UPDATE case I tried to implement:

DATA = STR_TO_DATE( '$name_01', '%m/%d/%Y' )

Since I tried '%Y.%m.%d' , '%Y/%m/%d' , '%Y-%m-%d' , among others ...

In the database is as date as the field. Does anyone have any ideas?

    
asked by anonymous 19.11.2016 / 21:17

1 answer

4

If you are using 19.11.2016 the format should be %d.%m.%Y getting:

DATA = STR_TO_DATE('$name_01', '%d.%m.%Y')

%d refers to day, %m refers to month and %Y refers to year, . being the separator as well as its mask.

    
19.11.2016 / 21:23