Non-english dates with strftime
Working on a multi-lingual project and struggling to get strftime() to return non-English date names in PHP? Your server probably doesn’t have the locales you’re looking for. Write this in a terminal:
locale -a
This should return you the list of installed locales. If you don’t find yours in there, you can install it:
sudo locale-gen <locale_name>
For eg., for French you’d write:
sudo locale-gen fr_FR.utf8
Now use strftime to get the localised date:
setlocale(LC_TIME, “fr_FR.utf8“);
echo strftime(” The time is: %A %B %C”);
Neat.
Written by kanuj bhatnagar
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#