Juiste datum in PhP


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;

Theo van der Sluijs

Theo van der Sluijs (1975) is Software Development Manager at Bax-shop.nl. You can read more in dutch on his “Dutch Blog“, he also created Gebruikmaar.nl. He is a member of the Board of the Dutch Flex Usergroup and Goesweb.net.

Google+ Twitter LinkedIn 



VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

No related posts.

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes