Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using locale in PHP on OS X UNIX
I was looking around, trying to find out how to get locale to work in PHP on OS X. After some searching, I found the solution and wanted to share this to save you some work. In Linux, one can do this:
setlocale(LC_ALL, 'nb_NO');
echo strftime(" %A %e %B %Y ");
To get it work in PHP on OS X, you must write it like this:
// set date format to Norwegian:
setlocale (LC_TIME, "no_NO.UTF-8");
// output the date
gmstrftime('%A %e %B %Y, %H:%M');
locale is probably not in your profile path, so you have to look in the locale folder to find your language:
$ ls /usr/share/locale
There you can find the languages you can use; some languages have different locale versions. Note that the encoding of the page must correspond to the locale you are using. That is, if you use no_NO.UTF-8, then you must have in your head:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Take a look at some date formatting tips for gmstrftime for more help.

[robg adds: I haven't tested this one.]
  • Currently 3.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)

Using locale in PHP on OS X | 0 comments | Create New Account
Click here to return to the 'Using locale in PHP on OS X' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.