add english ordinal suffix to day

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
streever

add english ordinal suffix to day

Post 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?
Last edited by streever on Sat Nov 03, 2007 8:27 pm, edited 1 time in total.
Locked

Return to “CMSMS Core”