Convert miliseconds into seconds, hours, days, mins

Discussion in 'JavaScript' started by gerbil249, Jan 25, 2012.

  1. #1
    So I'm creating this and I need help, what would I do?

    I want it to ask the user for the miliseconds then convert it.

    So it would be

    varhere = prompt("Enter miliseconds: ")

    what would be the code?
     
    gerbil249, Jan 25, 2012 IP
  2. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #2
    It is simple math. You know how many milliseconds are in each second. You know how many seconds there are in each minute. You know how many minutes there are in each hour. You know how many hours there are in each day. Just do the math.
     
    mmerlinn, Jan 25, 2012 IP
  3. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #3
    to get seconds, you need to divide it to 1000
    to get minutes, divide it to 1000 then 60
    to get hours, divide it to 1000 then 60 then 60 again
    to get days, divide it to 1000 then 60 then 60 again then 24
     
    JohnnySchultz, Jan 30, 2012 IP