CFLib.org – Common Function Library Project

CFChartDateFormat(date)

Last updated October 18, 2002
Download UDF

author

Rob Brooks-Bilson                                 Rob Brooks-Bilson

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

Description:
Formats a date/time value for use on the y-axis in CFCHART. CFCHART expects date/time values in epoch seconds, adjusted to UTC offset, and multiplied by 1000. Very strange, but it works.

Return Values:
Returns a numeric value.

Example:

<CFCHART FORMAT="Flash" LABELFORMAT="Date" SCALEFROM="12/31/1998">
<CFCHARTSERIES TYPE="Scatter" SERIESLABEL="New Years Eve Party Hosts">
<CFCHARTDATA ITEM="Zack" VALUE="#cfchartDateFormat("12/31/1972")#">
<CFCHARTDATA ITEM="Becky" VALUE="#cfchartDateFormat("12/31/1996")#">
<CFCHARTDATA ITEM="Joe" VALUE="#cfchartDateFormat("12/31/1984")#">
<CFCHARTDATA ITEM="Lynda" VALUE="#cfchartDateFormat("12/31/2002")#">
</CFCHARTSERIES>
</CFCHART>

Parameters:

Name Description Required
date Date/time value you want formatted for CFCHART. Yes

Full UDF Source:

<cfscript>
/**
* Formats a date/time value for use on the y-axis in CFCHART.
*
* @param date      Date/time value you want formatted for CFCHART. (Required)
* @return Returns a numeric value.
* @author Rob Brooks-Bilson (rbils@amkor.com)
* @version 1, October 18, 2002
*/

function cfchartDateFormat() {
var datetime = 0;
if (ArrayLen(Arguments) eq 0) {
datetime = Now();
}
else {
datetime = arguments[1];
}
return numberFormat(DateDiff("s", DateConvert("utc2Local", "January 1 1970 00:00"), datetime) * 1000);
}
</cfscript>

Search CFLib.org


Latest Additions

Jose Diaz-Salcedo Jose Diaz-Salcedo added
cfRssFeed
2 day(s) ago

Raymond Compton Raymond Compton added
structBlend
23 day(s) ago

Duncan Duncan added
IsZIPUK
23 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
29 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson