mv92
6/19/2017 - 2:02 PM

seconds to "H:M:S" string convert function

seconds to "H:M:S" string convert function from stackoverflow

function secToHMS(input,type='') {
  let list = ['object','obj','o','O','Obj','Object'];
  let check = list.findIndex(function (item) { if (item === type) return item });
  let h,m,s,temp1;
  h = Math.floor(input / 3600);
  temp1 = input - (h * 3600);
  m = Math.floor(temp1 / 60);
  s = Math.ceil(temp1 % 60);
  if (check > 0) {
    return {'h': h, 'm':m,'s':s,'raw':input, 'formated': ''+h+':'+m+':'+s+''};
  } else {
    return ''+h+':'+m+':'+s+'';
  }
}