note 27929 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:51:32 +0000
Subject: note 27929 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58274@lists.php.net to get a copy of this message
Note Submitter: brain@blunkweb.de ---- this function will convert any M-character in the format string to the full name of the corresponding month as defined in array $month function format_date($timestamp,$format) { $month = array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); preg_match_all("/[[:alpha:]]/",$format,$character); for($i=0;$i<count($character[0]);$i++) { if($character[0][$i] == 'M') { $formatted = $month[date("n",$timestamp)-1]; } else { $formatted = date($character[0][$i],$timestamp); } $format = preg_replace("/".$character[0][$i]."/",$formatted,$format,1); } return($format); } example: $timestamp = "1039786744"; echo format_date($timestamp,"d. M Y H:i:s"); output: 13. Dezember 2002 14:39:04

« previous php.notes (#58274) next »