Published
- 1 min read
showing difference between dates in minutes js
The solution for this is noted below
showing difference between dates in minutes js
Solution
const today = new Date()
const endDate = new Date(startDate.setDate(startDate.getDate() + 7))
const days = parseInt((endDate - today) / (1000 * 60 * 60 * 24))
const hours = parseInt((Math.abs(endDate - today) / (1000 * 60 * 60)) % 24)
const minutes = parseInt((Math.abs(endDate.getTime() - today.getTime()) / (1000 * 60)) % 60)
const seconds = parseInt((Math.abs(endDate.getTime() - today.getTime()) / 1000) % 60)
Try other methods by searching on the site. That is if this doesn’t work