note 55616 added to function.strftime

From: Date: Mon, 08 Aug 2005 22:28:50 +0000
Subject: note 55616 added to function.strftime
Groups: php.notes 
Request: Send a blank email to php-notes+get-93278@lists.php.net to get a copy of this message
I was sure i found a script on php.net wich add the ("st", "nd", "rd", "th") behind a daynumber, but i wasn't. So i wrote a tiny function to do that: <?php function &daySufix ($dayNumber = false){ (string) $dayNumber = (!$dayNumber) ? strftime ("%#d") : $dayNumber; $sufixes = Array ("1" => "st", "2" => "nd", "3" => "rd"); return (isset ($sufixes[$dayNumber])) ? $sufixes[$dayNumber] : "th"; } ?> Use it as follow: <?php echo strftime ("%A, %b. %#d" . daySufix() . " %Y"); ?> ---- Manual Page -- http://www.php.net/manual/en/function.strftime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55616 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55616&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55616&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93278) next »