SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: MP3 timer

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Location
    HOTLANTA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MP3 timer

    I'm pulling in a podcast feed and I want to show a timer in the following format 00:00:00 or hours:minutes:seconds. I am assuming that I should use
    Code:
    var d = new Date();
    var elapsed = d.getTime() - startTime;
    Thanks!

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hours --> Math.floor(totalmillis/(1000*60*60) )
    totalmillis -= hours * 1000 * 60 * 60;

    minutes--->Math.floor(totalmillis/(1000*60) )
    totalmillis -= minutes * 1000 * 60

    seconds = Math.floor(totalmillis/1000);

    var time = hours + ":" + minutes + ":" + seconds;

    Oh, yeah. You need some if statements to test if hours, minutes, seconds are less than 10. If so, then add a leading zero, e.g. hours = "0" + hours;
    Last edited by 7stud; Jan 25, 2007 at 21:43.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Location
    HOTLANTA
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay so I plugged this into an object named episode_timer and and it traces back as undefined, i put it all in a function called timer and it returned function timer()

    any other tips on how to use this bit of code...this is my first interaction with javascript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •