DEV Community

Julian
Julian

Posted on

How to Convert date format to PHP with MYSQLI, using secure queries to avoid SQL injection

There are cases in which we need to send a date format in Spanish to a sql query, for example the format of (Abril 28 2020) and for this we must do the following:

$ query = mysqli_query ($ conn, "SET lc_time_names = 'es_ES';");

$ query = $ conn-> prepare ('SELECT id, DATE_FORMAT (date, "% M% d% Y") ,, text FROM table WHERE id =?');

Keep in mind that these queries are what we should do in our developments to avoid sql injection.

Top comments (0)