That’s pretty simple if you already have a Date
object:
var coeff = 1000 * 60 * 5;
var date = new Date(); //or use any other date
var rounded = new Date(Math.round(date.getTime() / coeff) * coeff)
More Related Contents:
- Hover over image to get a box with multiple links in html/JavaScript
- Array data to be filled into a table using JavaScript
- What’s the best way to convert a number to a string in JavaScript?
- Is useState synchronous? [duplicate]
- How can I create every combination possible for the contents of two arrays?
- HTML5 Canvas to PNG File
- “var” or no “var” in JavaScript’s “for-in” loop?
- How to get the hours difference between two date objects? [duplicate]
- Is there any one-line analogy in ES6 for ES5 `module.exports = require(‘./inner.js’)`?
- Prevent anchor behaviour
- Do objects pushed into an array in javascript deep or shallow copy?
- Function and variable with the same name
- change html text from link with jquery
- ES6 `export * from import`?
- How to convert image to byte array using javascript only to store image on sql server?
- When should I automatically create an object even if `new` is forgotten?
- What is the difference between if(!!condition) and if(condition)
- Use firebase cloud function to send POST request to non-google server
- The reason to use JS .call() method?
- Is there any polyfill for current CSS Flexible Box Layout Module as per W3C CR (display: flex etc.)? [closed]
- How can I duplicate a div onclick event?
- Refresh element generated by a django template
- Is there a way to know if a link/script is still pending or has it failed
- Why I am not getting warnings about StrictNullChecks in typescript
- How do I set path while saving a cookie value in JavaScript?
- Datatables TypeError: c is undefined
- setTimeout() method inside a while loop [duplicate]
- How to highlight a part part of an Input text field in HTML using Javascript or JQuery
- Tag-like autocompletion and caret/cursor movement in contenteditable elements
- How to prevent Next.js from instantiating a singleton class/object multiple times?