JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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, 02: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, 03: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: 703 marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)marnixR User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 23 h 3 m 33 sec
Reputation Power: 487
70 modulo 60, which in javascript is written as
Code:
70 % 60
__________________
admin of Philosophorum - now well in its third year and still as modest as ever

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, 07: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 4 sec
Reputation Power: 13
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, 08:07 PM
David_B David_B is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 49 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: 17 h 9 m 6 sec
Reputation Power: 9
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


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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek