I am having a slider here. Below is the code of its function:
const [durationPercentage, setDurationPercentage] = useState(0);
const [maxDuration, setMaxDuration] = useState("06:00");
useEffect(() => {
const durationMax = maxDuration.replace(":", "");
const duration = (Number(durationMax) * durationPercentage) / 100;
var a = String(duration);
var b = ":";
var position = String(duration).length - 2;
var output = [a.slice(0, position), b, a.slice(position)].join("");
console.log(output);
}, [durationPercentage]);
/*========== Slider ===============*/
<Slider
onChange={(event, newDurationPercentage) =>
setDurationPercentage(newDurationPercentage)
}
/>
When I slides the slider, I am getting the result(s):

But, as you can see, after the : there are numbers greater than 60. When the numbers greater than or equal to 60 comes, I want the minute to increase by 1.
That is: When the slider slides, I want the result to be actually a valid time. Like: 01:04, 07:55 and not: 04:79, 01:88. The format would be mm:ss format.
Any help is greatly apperciated!
