note 55616 deleted from function.strftime by derick
| From: | derick@php.net | Date: | Sat, 04 Nov 2006 10:42:11 +0000 |
| Subject: | note 55616 deleted from function.strftime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119379@lists.php.net to get a copy of this message | ||
Note Submitter: fackelkind honorsociety de
----
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");
?>