Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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 …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

790 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