The request looks like this:

queryMysql("INSERT INTO tasks (deadline) VALUES(DATE_FORMAT('$deadline', '%d.%m.%Y')); 

But for some reason DATE_FORMAT ignored and DATE_FORMAT recorded in the database as 2020-05-20, how to fix it?

  • one
    And what type of field? If not a string, then nothing surprising. (btw I see you have sqlInjection here) - zb '
  • Type field date, it will not work? - tanias08

1 answer 1

Type date stores how it [DB] is more convenient.
If you want it to be more convenient for you, then take a string.

  • Changed. Here, miracles begin: when entering from DATE_FORMAT on 03/15/2001 it turns into 01/20/2015, and when withdrawing, again from DATE_FORMAT, in 05/20/2020 - tanias08
  • Somewhere, apparently, the server time settings are down ... - user31688
  • one
    And why do you even do DATE_FORMAT when insert? - zb '
  • one
    I'll tell you what - keep the time in TIMESTAMP, and format it in a language that operates from the database. It is very convenient and practical. - user31688
  • because when the date field is formatted, the date was recorded incorrectly, I thought it was in the format. with the varchar field format and without DATE_FORMAT, all problems have disappeared, thank you (True, now the comparison of the current date and the date from the database> _> works incorrectly) but this is another story) - tanias08