Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

from milliseconds to hours in js

function msToTime(duration) {
  var milliseconds = parseInt((duration % 1000) / 100),
    seconds = Math.floor((duration / 1000) % 60),
    minutes = Math.floor((duration / (1000 * 60)) % 60),
    hours = Math.floor((duration / (1000 * 60 * 60)) % 24);

  hours = (hours < 10) ? "0" + hours : hours;
  minutes = (minutes < 10) ? "0" + minutes : minutes;
  seconds = (seconds < 10) ? "0" + seconds : seconds;

  return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
}
console.log(msToTime(300000))
Comment

convert milliseconds to minutes and seconds javascript

const millisToMinutesAndSeconds = (millis) => {
    var minutes = Math.floor(millis / 60000);
    var seconds = ((millis % 60000) / 1000).toFixed(0);
	//ES6 interpolated literals/template literals 
  	//If seconds is less than 10 put a zero in front.
    return `${minutes}:${(seconds < 10 ? "0" : "")}${seconds}`;
}
    
Comment

PREVIOUS NEXT
Code Example
Javascript :: Installation de react native maps bibliothèque 
Javascript :: history go back js oneline 
Javascript :: regex not before 
Javascript :: jquery show function to javascript code 
Javascript :: freecodecamp Drop it 
Javascript :: how to give id dynamically in javascript 
Javascript :: copy Konva Transform object 
Javascript :: create-react-app height issues with flex 
Javascript :: how to generate debug build in react native 
Javascript :: value.js package 
Javascript :: add multiple parameters js 
Javascript :: firebase is there a way to rename a document 
Javascript :: socket io across two different ports 
Javascript :: react and express 
Javascript :: Mapping an Array to Elements with v-for 
Javascript :: how-to-show-a-confirm-message-before-delete 
Javascript :: getters and setters in java script 
Javascript :: crypto digest node.js 
Javascript :: add html symbols with javascript 
Javascript :: node_modules imers-browserifymain.js 
Javascript :: form handling in next js 
Javascript :: add google maps nuxt js 
Javascript :: know if a gridview is empty from javascript 
Javascript :: c# to json online 
Javascript :: npm password validator 
Javascript :: imleç 
Javascript :: SH1 in react native 
Javascript :: check if the last character of word is "A" 
Javascript :: jquery init dropdown 
Javascript :: Passing arrays to functions with the spread operator 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =