On our store we have a blog where we show the "created_at" date of the entity. But we show the same post to 5 different languages. Of course the content is translated but we don't know how we should translate the date.

Currently we display it like this:

$date = date("d F, Y", strtotime($date)); // $date = 2019-04-16 08:45:25
echo "<span> " . $date . "</span>";

This outputs something like this:

enter image description here

Our main problem here is that the month is in english in all our languages. Is there a way to translate just the month?

PS: According to our PM just using the month number is not an option.


To format dates in other languages, you should use the setlocale() and strftime() functions.

setlocale(LC_TIME, "fr_FR"); // Here fr_FR is your translation locale
echo strftime("%d %B, %Y");

Hope it finds helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.