Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

30 mins 24 hours jquery loop

var x = 30; //minutes interval
var times = []; // time array
var tt = 0; // start time
var ap = ['AM', 'PM']; // AM-PM

//loop to increment the time and push results in array
for (var i=0;tt<24*60; i++) {
  var hh = Math.floor(tt/60); // getting hours of day in 0-24 format
  var mm = (tt%60); // getting minutes of the hour in 0-55 format
  times[i] = ("0" + (hh % 12)).slice(-2) + ':' + ("0" + mm).slice(-2) + ap[Math.floor(hh/12)]; // pushing data in array in [00:00 - 12:00 AM/PM format]
  tt = tt + x;
}

console.log(times);
Comment

PREVIOUS NEXT
Code Example
Javascript :: node js gitignore 
Javascript :: hot get access_token instead of url 
Javascript :: simbu react1 
Javascript :: object assign js 
Javascript :: javascript remove elements from array with value 
Javascript :: javascript object array sum of values in object 
Javascript :: javascript add item in list 
Javascript :: split text javascript 
Javascript :: javascript generate random string from array 
Javascript :: angular keyframes % 
Javascript :: sort dates javascript 
Javascript :: javascript decrement 
Javascript :: javascript append to object 
Javascript :: how to change currency in react-paypal-button-v2 
Javascript :: register service worker 
Javascript :: react fetch request with content type x-www-form-urlencoded 
Javascript :: Implementing state lifecycle in react class component 
Javascript :: javascript most frequent in a list 
Javascript :: bash sort json alphabetically 
Javascript :: cross origin http://localhost forbidden jest 
Javascript :: leafletjs openstreets example 
Javascript :: Ocultar un elemento cuando la ventana cambia de tamaño css 
Javascript :: split 
Javascript :: a tag how to trigger ajax 
Javascript :: slice 
Javascript :: get window url from a browser extension 
Javascript :: this js 
Javascript :: javascript for pop up 
Javascript :: update object within object by id js 
Javascript :: You are trying to create a styled element with an undefined component.You may have forgotten to import it. 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =