thumb_scriptingWell everybody knows this problem.

You want to display a nice date on your PhP site (e.g. Tuesday, 15 February 2008) but it doesn’t do it in your own language.

Like me, I always want to display the date in the dutch language. Today I made new page on my www.gebruikmaar.nl page to display the week numbers. (weeknummers.gebruikmaar.nl). But even with the setlocal (setlocale(LC_ALL, ‘nl_NL’);) on nl_NL it did not work… it shows English weekdays and month name…. so… I decided to make a general script that does this for me… no matter what the language settings are.

Here’s that script.

$month = date( "n" );
$monthday = date( "j" );
$weekday = date( "w" );
$year =  date( "Y" );

$arrDays = array('Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag');
 $arrMonths = array('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus',
 'September', 'Oktober', 'November', 'December') ;

$monthname = $arrMonths[$month];
$dayname = $arrDays[$weekday];
$today = $dayname.", ".$monthday." ".$monthname." ".$year;
echo $today;

About the author

Theo van der Sluijs Theo van der Sluijs (1975) is Lead Developer at Unitrust BV. He is also creator of "I Am Bored So I blog" / Gebruikmaar.nl / vanderSluijs.nl. He is a member of the Board of the Dutch Flex Usergroup and Goesweb.net. With his quote "Never Give Up, Never Surrender" (Actually stolen from Galaxy Quest) he fights his way through the day. Connect with him on Twitter.

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)

Leave a Reply

QR Code
Donate

Like the information on my site? Please donate for a cup of coffee, or give a bit more for a cappuccino.

Twitter
Get Adobe Flash playerPlugin by wpburn.com wordpress themes