JSFiddle - React, Tailwind, and code Playground

by rakesh makluri

JavaScript

function formatDuration(duration) {

// calculate (and subtract) whole days
var days = Math.floor(duration / 86400);
delta -= days * 86400;

// calculate (and subtract) whole hours
var hours = Math.floor(delta / 3600) % 24;
delta -= hours * 3600;

// calculate (and subtract) whole minutes
var minutes = Math.floor(delta / 60) % 60;
delta -= minutes * 60;

// what's left is seconds
var seconds = delta % 60;
}