How can I run a Javascript loop with a 15 min time interval? It should use 24 hour format. For example, running from 6:00 am to 11:45 pm it would run at 6:00,6:15, 6:30 --- 23:45 etc. These values are displayed as pulldown menu items in html. I am using notepad for javascript and html because I am required to.
Asked
Active
Viewed 5,382 times
3
-
1I'm confused. Are you trying to create a list of times with 15 minute intervals, or to run some thing every 15 minutes from some arbitrary start time, or from a particular start time, or to run something at specific times that just happen to be at 15 minutes intervals? – RobG May 28 '13 at 06:09
-
Don't downvote for a new bee... – Prasath K May 28 '13 at 06:19
-
1no dont want to run somthing in evry 15 min – sin May 28 '13 at 06:30
-
http://stackoverflow.com/questions/1197928/how-to-add-30-minutes-to-a-javascript-date-object This might be helpful for you I think. – Ms. Nobody May 28 '13 at 06:40
1 Answers
8
setInterval(function() {
// I will run for every 15 minutes
}, 15 * 60 * 1000);

PSR
- 39,804
- 41
- 111
- 151
-
-
-
Thanq but we dont use any functions just use for loop to iterate the intervals – sin May 28 '13 at 06:20
-
no dont want to run somthing in evry 15 min my requirment is two text boxes start time and end time when we click on start time text box is shows the list items as 6:00 ,6:15,6:30 ----23:45 thats it and selected values displayes in text box need to write basic same as end time also – sin May 28 '13 at 06:38
-
1use getTime() in the function to check if you are in your desired period and run script or not. It's not possible give js fixed timestamps like you want. But if you can assume to start the script at specific time, you may consider nesting setInterval(). One for every 15 minutes and one wrapping e.g. with 6h.... – Karl Adler May 28 '13 at 06:39