Format date in INSERT and UPDATE Mysql PHP

Asked

Viewed 368 times

3

Well I have a registration Gride with date, only I have to use a Mask of Jquery:

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

But when I do an INSERT, for example, the date 19.11.2016 turns into 21.11.2019. This same case happens with the UPDATE.

In the case of UPDATE I tried to implement:

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

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

In the database it’s like date the field. Does anyone have any idea?

  • 1

    %d. %m.%Y you have tried?

  • @Sorack Ita! do not believe that was it. It gave up shame now ...

  • I will put the answer with a brief explanation

  • You don’t have to be ashamed to make a mistake. I posted the answer, if you can accept pressing the V next to it to serve as reference for someone with similar doubt I thank you

1 answer

4


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

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

The %drefers to the day, the %m refers to the month and the %Y refers to the year, where the . is the separator as well as its mask.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.