You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
692 B
23 lines
692 B
function millisecondsToTime(milliseconds) {
|
|
const seconds = Math.floor((milliseconds / 1000) % 60);
|
|
const minutes = Math.floor((milliseconds / (1000 * 60)) % 60);
|
|
const hours = Math.floor((milliseconds / (1000 * 60 * 60)) % 24);
|
|
return { hours, minutes, seconds };
|
|
}
|
|
|
|
export default function MillisecondsToString(milliseconds) {
|
|
const { hours, minutes, seconds } = millisecondsToTime(milliseconds);
|
|
let timeVal = "";
|
|
if (hours > 0) {
|
|
timeVal = hours.toString();
|
|
timeVal += ":";
|
|
timeVal += minutes.toString().padStart(2, "0");
|
|
}
|
|
else {
|
|
timeVal += minutes.toString();
|
|
}
|
|
timeVal += ":";
|
|
timeVal += seconds.toString().padStart(2, "0");
|
|
return timeVal;
|
|
}
|