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
Tayo Akinmade added
arrayTrim
4 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)