Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get next 15min

let interval = 5 * 60 * 1000;  // 5min in ms
let myDate = new Date(); // date that should be round to next 5min

// date with next/future 5min
let newDate = new Date(Math.ceil(myDate / interval) * interval);
// note: for NEAREST 5min interval, use Math.round()

// examples
// myDate('2022-08-11 08:01:18') -> newDate = '2022-08-11 08:05:00'
// myDate('2022-08-11 08:04:59') -> newDate = '2022-08-11 08:05:00'
// myDate('2022-08-11 08:50:08') -> newDate = '2022-08-11 08:55:00'
// myDate('2022-08-11 08:57:14') -> newDate = '2022-08-11 09:00:00'
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get keys from request headers in express 
Javascript :: how to convert an array into single quote strings 
Javascript :: npm request 
Javascript :: price range slider bootstrap 4 
Javascript :: redux update item in array 
Javascript :: 2d array in js 
Javascript :: get input js 
Javascript :: try catch async await 
Javascript :: string match 
Javascript :: react native firebase email verification 
Javascript :: process return value 
Javascript :: add next to react 
Javascript :: how to install nide js in ubuntu 
Javascript :: js store regex in variable and combine 
Javascript :: hashtable js 
Javascript :: Download excel using reactJS 
Javascript :: passport jwt npm 
Javascript :: uppercase-the-first-letter-of-a-string-using-javascript/ 
Javascript :: jquery selector class child 
Javascript :: How can I check if an object is an array 
Javascript :: validate email or phone js 
Javascript :: expres body parser 
Javascript :: Minimal Project Angular 
Javascript :: foreach method javascript 
Javascript :: react native gif dont work 
Javascript :: get index vanilla js 
Javascript :: ternary operator jquery 
Javascript :: instalar bootstrap en react 
Javascript :: add even numbers recursion js 
Javascript :: javascript continue with for Loop 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =