SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up converting milliseconds to hours and minutes

    I have 2 Date objects and count down from now to ready,
    and show it in the format of "00 HOURS and 00 MINS."
    Code:
    var now:Date = new Date();
    var ready:Date = new Date(2008,9,10,12,0,0);
    
    var dif:Number = (ready.valueOf() - now.valueOf());
    trace(dif);
    How can I convert difference to HOUR + MIN?

    Please help.

    P.S. I`m using A.S. 3.0

  2. #2
    SitePoint Guru krityx's Avatar
    Join Date
    Jan 2006
    Location
    Around
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if the variable value contains the time in miliseconds then
    Code:
    var hr:Number = Math.floor(value / 3600000);
    var min:Number = Math.floor((value % 3600000) / 60000);
    1 s = 1000 ms
    1 hr = 3600 s = (3600 * 1000) ms = 3600000 ms
    1 min = 60 s = (60 * 1000) ms = 60000 ms



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
  •