note 29236 added to function.date
| From: | something_awesome at yahoo dot com | Date: | Thu, 06 Feb 2003 23:16:04 +0000 |
| Subject: | note 29236 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-43533@lists.php.net to get a copy of this message | ||
Here's another suffix creater, that I think does the job in fewer lines, if that is in any way
an advantage ;-)
given $date is in MySQL format yyyy-mm-dd
===
list ($year, $month, $day) = split ('-', $date);
$prefix = array(1 => 'st', 21 => 'st', 31 => 'st', 2 =>
'nd', 22 => 'nd', 3 => 'rd', 23 => 'rd');
$day = ($day * 1); //* Kills Leading 0 *//
if ($prefix[$day]) {
$day .=$prefix[$day];
}
else {
$day .='th';
}
===
However I am unsure how the "performance" of this code compares to the example able. Is
that trick with the day more costly than using a string function on it?
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+29236
http://master.php.net/manage/user-notes.php?action=delete+29236
http://master.php.net/manage/user-notes.php?action=reject+29236