View Single Post
Old 11-21-2003, 01:53 AM   PM User | #12
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
How about this; still a little kludgy, but it works
Code:
function getNumberSuffix(dNum)
{
	daySuffix = 'th';
	if(dNum != 11 && dNum != 12 && dNum != 13) 
	{
		if(dNum > 9) { dNum = dNum % 10; }
		if (dNum == 1) { daySuffix = 'st'; }
		if (dNum == 2) { daySuffix = 'nd'; }
		if (dNum == 3) { daySuffix = 'rd'; }
	}
	return daySuffix;
}
So you just call it like getNumberSuffix(14)
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote