milliseconds to seconds code example
Example 1: milliseconds to seconds C#
string l_Time = string.Format("{0} s", TimeSpan.FromMilliseconds(154820).TotalSeconds.ToString());
Example 2: convert milliseconds to time javascript
function msToTime(s) {
function pad(n, z) {
z = z || 2;
return ('00' + n).slice(-z);
}
var ms = s % 1000;
s = (s - ms) / 1000;
var secs = s % 60;
s = (s - secs) / 60;
var mins = s % 60;
var hrs = (s - mins) / 60;
return pad(hrs) + ':' + pad(mins) + ':' + pad(secs) + '.' + pad(ms, 3);
}
console.log(msToTime(55018))
Example 3: hrtime to milliseconds
var hrTime = process.hrtime()
console.log(hrTime[0] * 1000000 + hrTime[1] / 1000)