Skip to content

Instantly share code, notes, and snippets.

View Elius94's full-sized avatar
🏔️

Elia Lazzari Elius94

🏔️
View GitHub Profile
@Elius94
Elius94 / msconvert.js
Created March 10, 2016 14:21 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };