ColdFusion - How to loop over a time range

cfloop - loop over a time range

cflooptime.cfm



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfloop tag example: how to loop over a time range in coldfusion</title>
</head>

<body>
<h2 style="color:Crimson">cfloop Tag Example: time range</h2>

<cfset LoopStartTime=CreateTime(0,0,0)>
<cfset LoopEndTime=CreateTime(5,0,0)>

<cfoutput>
 <b>LoopStartTime:</b> #LoopStartTime#<br />
 <b>LoopEndTime:</b> #LoopEndTime#<br />
</cfoutput>
<br /><br />

Loop start[step 30 minutes] ...<br />

<cfloop from="#LoopStartTime#" to="#LoopEndTime#" index="i" step="#CreateTimeSpan(0,0,30,0)#">
 <cfoutput>
     <b>Current Position:</b> #TimeFormat(i)#<br />
    </cfoutput>
</cfloop>

</body>
</html>







More ColdFusion examples