CFLib.org – Common Function Library Project

CFChartDateFormat(date)

Last updated October 18, 2002

author

Rob Brooks-Bilson

Version: 1 | Requires: CF5 | 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:

/**
 * 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);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson