Skip to content

Instantly share code, notes, and snippets.

View yussan's full-sized avatar
🏠
Working from home everyday

yussan yussan

🏠
Working from home everyday
View GitHub Profile
@yussan
yussan / msToTime.js
Created October 6, 2021 13:23
Convert Miliseconds to hh:ii:ss:ms
/**
* @desc function to convert ms to time format hh:ii:ss.ms
* @param {Number} duration, time ini miliseconds
* @return {String} sample 00:01:01:99
*/
export function msToTime(duration = 0) {
let milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);