CFLib.org – Common Function Library Project

CFChartDateFormat(date)

Last updated October 18, 2002

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

 
Rated 1 time(s). Average Rating: 1.0

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:

view plain print about
<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:

view plain print about
<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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson