Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Simon Holywell: PHP date localisation with setlocale

Simon Holywell: PHP date localisation with setlocale

Simon Holywell as written up a tutorial for his site showing you how to use setlocale to do PHP date localization.

Localising sites can be a chore, but PHP has the venerable setlocale() to use system locales. These are like templates or profiles that describe how various types of data should be displayed. Should a price have a comma or point to indicate the decimals? When printing a date should PHP output Monday or Montag?

All of these considerations are locale specific and they map to a geographical area. Various cultures have their own standards for displaying this kind of information not to mention different languages to accommodate.

He shows how to find the locales your system supports and how to install them if the one(s) you need are missing. With it correctly installed, the system knows how to use it but PHP needs a little extra help. With a call to the setlocale method and the use of a special date string modifier (in this case “%B” for the month name) PHP knows to use the locale-aware version of the data…but only with strftime not the normal PHP date handling.

Link: https://www.simonholywell.com/post/2015/07/php-date-setlocale-localisation/
Source: http://www.phpdeveloper.org/news/22963

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Posted Lipiec 21st, 2015 in WEB and PHP Development.

Leave a response: