Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript parse time (minutes:seconds) from milliseconds

How to parse a given amount of milliseconds (e.g. 125230.41294642858) into a time format like: minutes:seconds?

like image 849
PeeHaa Avatar asked Apr 07 '11 22:04

PeeHaa


People also ask

How do you convert milliseconds to minutes and seconds?

Convert Milliseconds to minutes using the formula: minutes = (milliseconds/1000)/60). Convert Milliseconds to seconds using the formula: seconds = (milliseconds/1000)%60). The print output from Milliseconds to minutes and seconds.

How do you convert milliseconds to hours minutes seconds?

To convert milliseconds to hours, minutes, seconds:Divide the milliseconds by 1000 to get the seconds. Divide the seconds by 60 to get the minutes. Divide the minutes by 60 to get the hours. Add a leading zero if the values are less than 10 to format them consistently.

How do you convert milliseconds to minutes in typescript?

To convert milliseconds to hours and minutes: Divide the milliseconds by 1000 to get the seconds. Divide the seconds by 60 to get the minutes. Divide the minutes by 60 to get the hours.


1 Answers

var ms = 125230.41294642858,
   min = 0|(ms/1000/60),
   sec = 0|(ms/1000) % 60;

alert(min + ':' + sec);
like image 120
Nobody Avatar answered Oct 02 '22 22:10

Nobody