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)

DevCycle image

Ship Faster, Stay Flexible.

DevCycle is the first feature flag platform with OpenFeature built-in to every open source SDK, designed to help developers ship faster while avoiding vendor-lock in.

Start shipping

👋 Kindness is contagious

Dive into this insightful article, celebrated by the caring DEV Community. Programmers from all walks of life are invited to share and expand our collective wisdom.

A simple thank-you can make someone’s day—drop your kudos in the comments!

On DEV, spreading knowledge paves the way and strengthens our community ties. If this piece helped you, a brief note of appreciation to the author truly counts.

Let’s Go!