langel
langel

Reputation: 99

Function to show date with language specifics in PHP

Does anyone know how to make a little function for date in PHP, and if possible, a way to change the function language.

Upvotes: 2

Views: 286

Answers (1)

Sander Marechal
Sander Marechal

Reputation: 23216

I'd use the IntlDateFormatter class from the PHP's intl extension. The nice thing about the intl extension is that it does not rely on system locales to be present/installed.

If installing system locales is no problem for you (or you can't get intl running) then have a look at strftime to format unix timestamps according to locale.

Edit: I just remembered I wrote a tutorial a few years ago about building the intl estension from source (on Debian): http://www.jejik.com/articles/2008/07/howto_build_and_install_the_intl_pecl_extension_for_php5_in_debian/

Upvotes: 3

Related Questions