Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Convert timepicker format "mm:ss" to miliseconds in javascript?

I have a string in the timepicker format "mm:ss", I would like to convert this to milliseconds so I can include it in a setTimeOut. Here is an example of what I intend to do.

let minSeconds="03:30";
let milisenconds= convertMinSeconds(minSeconds)

setTimeout((){
 console.log("finish");
},milisenconds)

I don't know if there is an effective way to do this using javascript.

How can I do it? thank you very much

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can try something like this

let minSeconds="03:30";
let milisenconds= convertMinSeconds(minSeconds)
function convertMinSeconds(minSeconds) {
  let splitted = minSeconds.split(':')
  let min = Number(splitted[0])
  let second = Number(splitted[1])
  let allInSecond = min*60 + second
  let inMilisecond = allInSecond * 1000
  return inMilisecond
}

setTimeout(() => {
 console.log("finish");
},milisenconds)

about 4 years ago · Juan Pablo Isaza Report

0

this function will solve the problem

const ms = (time)=>{
 const [min , sec] = time.split(':')
 return  ms = ((Number(min) * 60) + Number(sec)) * 1000
}
about 4 years ago · Juan Pablo Isaza Report

0

node
let minSeconds="03:30";
undefined
let miliseconds=new Date("1970-01-01T00:" + minSeconds + "Z").getTime()
undefined
console.log(miliseconds)
210000
undefined
node --version
v10.19.0
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!