note 29311 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:52:52 +0000
Subject: note 29311 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58279@lists.php.net to get a copy of this message
Note Submitter: freesoftware@xs4all.nl ---- Here's another example of how to replace English month and weekday names into another language (Dutch in this example): function formatdate($timestamp, $format) { $weekdays = array('zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'); $months = array('januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'); preg_match_all('/[\\\]*[a-zA-Z]/', $format, $character); for($i = 0; $i < count($character[0]); $i++) { switch ($character[0][$i]) { case 'F': $character[1][$i] = $months[date('n', $timestamp)-1]; break; case 'M': $character[1][$i] = substr($months[date('n', $timestamp)-1], 0, 3); break; case 'l': $character[1][$i] = $weekdays[date('w', $timestamp)]; break; case 'D': $character[1][$i] = substr($weekdays[date('w', $timestamp)], 0, 3); break; default: $character[1][$i] = date($character[0][$i], $timestamp); } } $i = 0; $format = preg_replace('/[\\\]*[a-zA-Z]/e', "\$character[1][\$i++]", $format); return $format; }

« previous php.notes (#58279) next »