Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript date get future 15 minutes

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

// date with nearest 15min
let newDate = new Date(Math.round(myDate / interval) * interval); 
// note: for NEXT 15min interval, use Math.ceil()

// examples
// myDate('2022-08-11 09:05:13') -> newDate = '2022-08-11 09:00:00'
// myDate('2022-08-11 09:08:11') -> newDate = '2022-08-11 09:15:00'
// myDate('2022-08-11 09:51:16') -> newDate = '2022-08-11 09:45:00'
// myDate('2022-08-11 09:52:48') -> newDate = '2022-08-11 10:00:00'
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery visible 
Javascript :: push items to associative array jquery 
Javascript :: react native get mac address 
Javascript :: javascript innerwidth 
Javascript :: react router multiple path 
Javascript :: how do i make a link to direct me to a new page when i click on a button in react 
Javascript :: iterate object js 
Javascript :: vertical align text canvas 
Javascript :: jquery replace h1 with h2 
Javascript :: fs.writefilesync in nodejs 
Javascript :: time calculator js 
Javascript :: pauze js 
Javascript :: dice roller javascript 
Javascript :: nativescript absolutelayout bottom 
Javascript :: fluttter http get 
Javascript :: assign key and value to object 
Javascript :: get url params with js 
Javascript :: usereducer hook react 
Javascript :: encodeuricomponent js 
Javascript :: prop-types install npm 
Javascript :: get hours and minutes and seconds from date in javascript 
Javascript :: nestjs change httpcode inside function 
Javascript :: REACt helmet og tags DONT WORK 
Javascript :: jest match object properties 
Javascript :: count duplicate elements in array javascript 
Javascript :: include jsp in another jsp 
Javascript :: last element of array js 
Javascript :: Confirm the Ending 
Javascript :: how to edit website in browser using javascript on google chrome 
Javascript :: datatables dynamically hide columns 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =