Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript date get next 15 minutes

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 :: Implement stack as an abstract data type using singly linked list and use this ADT for conversion of infix expression to postfix, prefix and evaluation of postfix and prefix expression. 
Javascript :: pattern alphabet and space 
Javascript :: get request with axios 
Javascript :: learn nestjs 
Javascript :: javascript how to get last property of object 
Javascript :: for loop javascript 
Javascript :: find an object from array of objects javascript 
Javascript :: using apis in javascript 
Javascript :: string match method 
Javascript :: react buffer to image 
Javascript :: process exit code 
Javascript :: how to replace all occurrences of a string in javascript 
Javascript :: how to change icon from play to pause in javascript 
Javascript :: convert curl response to json format and echo the data 
Javascript :: react html parser 
Javascript :: mongodb replace string 
Javascript :: add items to a react array in hooks 
Javascript :: javascript speech recognition 
Javascript :: js date to timestamp 
Javascript :: password regex 
Javascript :: anjular js 
Javascript :: how to export module in node js 
Javascript :: how to remove the desimal numbers in javascript 
Javascript :: online python to c converter 
Javascript :: angular right click action 
Javascript :: mod operation in shopify 
Javascript :: fibonacci recursion 
Javascript :: resize image in node.js 
Javascript :: for:each in lwc js 
Javascript :: sequelize raw query 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =