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);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson