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)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay