Page 1 of 1

add english ordinal suffix to day

Posted: Sat Nov 03, 2007 8:01 pm
by streever
Hi all,

Wow, I've spent 4 hours on this!

I wrote a UDT:
it returns the suffix.

BUT how do I pass the NUMBER of the day to the UDT???

UDT IS BELOW!
In my template, I just call it by name: {getSuffix}

any help--sooooo appreciated.

Code: Select all

{
$nn = $n % 100; 
if ($nn > 3 && $nn < 21) { 
return $n . 'th'; 
} 
switch ($nn % 10) { 
case '1': return $n . 'st'; 
case '2': return $n . 'nd'; 
case '3': return $n . 'rd'; 
default: return $n . 'th'; 
} 
}
$list = ''; 
for ($n = 1; $n < 150; $n++) { 
$list .= "$n: " . getEnglishOrdinalsuffix($n) . "\n"; 
} 
print "<pre>$list</pre>";
NOTE: I HAVE CHANGED THE UDT!!! IT'S SIMPLER NOW:

Code: Select all

global $gCms;
$date = $event_date_start_day;
echo date('S');
ok so i get it to display the rd/th, etc, but only according to WHAT THE DAY CURRENTLY IS IN REAL LIFE!

I want it to use the day value from CALENDAR.

I tried $event_date_start_day and $day with no success.

How would I even pass these?

Can anyone help?