Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-08
5
Medium Priority
?
478 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
[X]
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
  • 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
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…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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