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)

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