DEV Community

Julian
Julian

Posted on

How to get the date in Spanish, with the format name of the month, day and year

It's normal that on a web page we want to print the date showing the name of the month, because normally what we do is print a date style 01/05/2020 and it is not ideal, since to view events in a program, blogs, among others the ideal format is to have the name of the month and in Spanish, since by default in Mysql the date appears in us format.

The following code was implemented within PHP and can be implemented for your programs:

$ res = mysqli_query ($ link, "SET lc_time_names = 'es_ES';");
$ res = mysqli_query ($ link, "SELECT id, title, DATE_FORMAT (date, '% M% d% Y') as date FROM table order by id desc limit 3");

Top comments (0)