JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 19th, 2006, 01:55 PM
fatnic388 fatnic388 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 13 fatnic388 User rank is Corporal (100 - 500 Reputation Level)fatnic388 User rank is Corporal (100 - 500 Reputation Level)fatnic388 User rank is Corporal (100 - 500 Reputation Level)fatnic388 User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 2 h 20 m 28 sec
Reputation Power: 0
Unhappy Convert seconds to minutes:seconds

Hi. I think i'm being a complete mathematical idiot, but how do you convert seconds (eg. 70) to minutes:seconds (1:10)? I'm drawing a complete blank!!! I've thought of dividing by 60 but what do you do with the remainder??

Can someone with a higher IQ than me please help?

Reply With Quote
  #2  
Old September 19th, 2006, 02:36 PM
marnixR's Avatar
marnixR marnixR is offline
i don't do negative rep
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2006
Posts: 760 marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level)marnixR User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 14 h 50 m 4 sec
Reputation Power: 705
Facebook
70 modulo 60, which in javascript is written as
Code:
70 % 60
__________________
some character references
universally acclaimed as "fundie of the worst kind"
"the stubborn old loser whose high point of the day is making immature remarks and counting his rep points on an internet message board"
stop bitching about lower case - it's my trademark™

Reply With Quote
  #3  
Old September 19th, 2006, 06:29 PM
BillyDunny BillyDunny is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2003
Posts: 508 BillyDunny User rank is Sergeant (500 - 2000 Reputation Level)BillyDunny User rank is Sergeant (500 - 2000 Reputation Level)BillyDunny User rank is Sergeant (500 - 2000 Reputation Level)BillyDunny User rank is Sergeant (500 - 2000 Reputation Level)BillyDunny User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 8 h 28 m 55 sec
Reputation Power: 16
Quote:
Originally Posted by marnixR
70 modulo 60, which in javascript is written as
Code:
70 % 60


To take a step further you could try this (i have not fully tested this):

javascript Code:
Original - javascript Code
  1. String.prototype.pad = function(l, s){
  2.     return (l -= this.length) > 0
  3.         ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length)
  4.         : this;
  5. };
  6.  
  7. var seconds = 121;
  8. document.write( Math.floor(seconds / 60) + ":" + (seconds % 60).toFixed().pad(2, "0") );

Reply With Quote
  #4  
Old September 19th, 2006, 07:07 PM
David_B David_B is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 67 David_B User rank is Sergeant (500 - 2000 Reputation Level)David_B User rank is Sergeant (500 - 2000 Reputation Level)David_B User rank is Sergeant (500 - 2000 Reputation Level)David_B User rank is Sergeant (500 - 2000 Reputation Level)David_B User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 1 h 30 m 9 sec
Reputation Power: 23
Quote:
Originally Posted by fatnic388
. . . how do you convert seconds (eg. 70) to minutes:seconds (1:10)?


I think you're going to need two variables: one to hold the minutes, the other to hold the seconds.

For example, something like the following (haven't tested):

Code:
secVar0 = 70;                            // The initial data, in seconds
minVar = Math.floor(secVar0/60);  // The minutes
secVar = secVar0 % 60;              // The balance of seconds


You should now have the minutes and seconds for further use or output however you like.

Regards,


David

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Convert seconds to minutes:seconds

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap