You need to convert a ColdFusion date into a JavaScript date object to use in your JavaScript code.
Create a small UDF for generating the necessary code to create a JavaScript date object from a ColdFusion date object.
The following UDF allows you to generate the necessary JavaScript code to use any ColdFusion date within the JavaScript on your page:
<cfscript>
function jsDateFormat(date){
if( isDate(date)) return 'new Date(#year(date)#,
#(month(date)-1)#, #day(date)#, #hour(date)#, #minute(date)#,
#second(date)#)';
else return "null";
}
</cfscript>
Now any time you need to use the date object within your JavaScript code, just do:
<script type="text/javascript"> var today = <cfoutput>#jsDateFormat(now())#</cfoutput>; alert(today); </script>
+