dateLetters(dateStr [, formatStr])
Last updated May 22, 2003
Version: 1 | Requires: ColdFusion 5 | Library: DateLib
Description:
This will return a given date in a long formated string including the optional letters ie 1st,2nd,3rd,4th etc.
Return Values:
Returns a string.
Example:
#dateLetters(now())#
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| dateStr | Date to use. | Yes |
| formatStr | Format string for month and year. | No |
Full UDF Source:
<cfscript>
/**
* Add's the st,nd,rd,th after a day of the month.
*
* @param dateStr Date to use. (Required)
* @param formatStr Format string for month and year. (Optional)
* @return Returns a string.
* @author Ian Winter (ian@defusionx.om)
* @version 1, May 22, 2003
*/
function dateLetters(dateStr) {
var letterList="st,nd,rd,th";
var domStr=DateFormat(dateStr,"d");
var domLetters='';
var formatStr = "";
if(arrayLen(arguments) gte 2) formatStr = dateFormat(dateStr,arguments[2]);
switch (domStr) {
case "1": case "21": case "31": domLetters=ListGetAt(letterList,'1'); break;
case "2": case "22": domLetters=ListGetAt(letterList,'2'); break;
case "3": case "23": domLetters=ListGetAt(letterList,'3'); break;
default: domLetters=ListGetAt(letterList,'4');
}
return domStr & domLetters & " " & formatStr;
}
</cfscript>
Search CFLib.org
Latest Additions
Alan McCollough added
forceBoolean
5 day(s) ago
Shawn Porter added
DeMoronize
8 day(s) ago
Chris Carey added
readPropertiesFi...
9 day(s) ago
Randy Johnson added
lastDayofWeek
11 day(s) ago
Top Rated
indentXml
Rated 5.0, 4 time(s)
QuickSort
Rated 5.0, 3 time(s)
queryColumnsToSt...
Rated 5.0, 3 time(s)
generateSsccAsn
Rated 5.0, 3 time(s)