Solved

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

Posted on 2008-10-08
5
430 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

896 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

14 Experts available now in Live!

Get 1:1 Help Now