Coding Global Background
Coding Global

Get amount of seconds, minutes, hours and days between two dates

Archived 3 years ago
1
7 messages
0 members
3 years ago
Open in Discord
J
Jordan

I'm looking to find the exact (or an approximate) amount of seconds, minutes & hours between an epoch time and the current date. I was hoping to use momentjs for this because I thought it would help Code: ```js let end = moment(new Date().getTime()) let start = moment(cooldown[context]) //Proper epoch time var duration = moment.duration(end.diff(start)); var between = { days: duration.days(), hours: duration.hours(), minutes: duration.asMinutes(), seconds: duration.asSeconds() } console.log(between)``` Console Output: ```js { days: 6, hours: 6, minutes: 27884526.431066666, seconds: 1673071585.864 }```

Replies (7)