Solved

ColdFusion - Need to create a list of times in 15 minute increments

Posted on 2008-10-08
5
422 Views
Last Modified: 2011-10-19
I need a drop down menu that displays a list of times that increment every 15 minutes.  So something like this:

12:00:00:AM
12:15:00:AM
12:30:00:AM
12:45:00:AM
01:00:00:AM
01:15:00:AM
01:30:00:AM
01:45:00:AM
02:00:00:AM
02:15:00:AM
02:30:00:AM
02:45:00:AM
03:00:00:AM
etc...

I have some code to do it but it ends up erroring after it hits 11:45:00:PM.  I've attached the code that I have and an image of the error.

I'm not married to this code so if you have another example that works please point me to it.

Thanks!
<cfset variables.minutes = "0,15,30,45">

<cfset variables.hours = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24">
 

    

<cfoutput>

<cfloop list="#variables.hours#" index="indexHours">

<cfloop list="#variables.minutes#" index="indexMinutes">

 <cfset variables.start_time = createTime(indexHours, indexMinutes, 00)>

 #timeformat(variables.start_time,"hh:mm:ss:tt")#<br />

</cfloop>

</cfloop>

</cfoutput>

Open in new window

calendar.gif
0
Comment
Question by:IRHusker
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22670969
well the reason it is doing this because the the hourse reaches their end and the loop do not nop what to do next
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 500 total points
ID: 22671025
http://www.coldfusionmuse.com/index.cfm/2008/9/17/cfloop.over.date.time

<ul>
<cfloop index="tm" from="8:00 AM" to="5:00 PM" step="#createTimespan(0,0,45,0)#">  
   <cfoutput> <li>#TimeFormat( tm, "h:mm TT" )#</li></cfoutput>
</cfloop>
</ul>
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22671027
http://www.bennadel.com/blog/684-Looping-Over-Times-In-ColdFusion.htm
<cfoutput>

<cfset dtHour = CreateTimeSpan(
0, <!--- Days. --->
0, <!--- Hours. --->
15, <!--- Minutes. --->
0 <!--- Seconds. --->
) />
 
 

<cfloop
index="dtTime"
from="8:00 AM"
to="8:00 PM"
step="#dtHour#">
 
#TimeFormat( dtTime, "hh:mm TT" )#<br />
 
</cfloop>
</cfoutput>
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 22671031
btw ... note the -cost- of the loop if you run it more than once in a single request
0
 

Author Closing Comment

by:IRHusker
ID: 31504330
Thanks bro!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now