PHP – Altering output of date()

This entry was posted by on Sunday, 3 October, 2010 at

PHP’s support for conversion of time-related things is outstanding, building calendars, schedules and the like is easy. When they are to be in English. What if we want it in Dutch?

A great help was this article on about.com by Angela Bradley. In short, it describes the converting a year-month-day into the string representation of the day:

$h = mktime(0, 0, 0, $month, $day, $year);
$d = date(“F dS, Y”, $h) ;
$w= date(“l”, $h) ;

Now echoing $w gives something like “Wednesday”. Nice, but now in Dutch. We are going to use a simple array construct for this:

$dagen[“Monday”]=”Maandag”;
$dagen[“Tuesday”]=”Dinsdag”;
$dagen[“Wednesday”]=”Woensdag”;
$dagen[“Thursday”]=”Donderdag”;
$dagen[“Friday”]=”Vrijdag”;
$dagen[“Saturday”]=”Zaterdag”;
$dagen[“Sunday”]=”Zondag”;

And now, when we echo $dagen[$w] we would get “Woensdag”.

Another option is using the NLDatum class, which overloads date() altogether.


Leave a Reply