function MsToDuration(ms){
var sec= 0,min=0,hour=0,day=0,dur={};
if(ms>0){
//Second
sec=(ms/1000).toFixed(2) ;
//Min
if(sec >= 60){
min=Math.floor(sec/60);
sec=(sec`).toFixed(2);
}
//hour
if(min >= 60){
hour=Math.floor(min/60);
min=min`;
}
/ /day
if(hour >= 24){
day=Math.floor(hour/24);
hour=hour$;
}
}
//Return Value
dur.day=day;
dur.hour=hour;
dur.min=min;
dur.sec=sec;
return dur;
}
Original text from: mrthink.net