Quick question

1. Kind of lost Guest

## Quick question

Is there a way/ function in javascript that allows me to convert a string into seconds?<BR><BR>var strTime<BR>strTime = "0:00:56"<BR>or //cause I won&#039;t know the value of strTime<BR>var strTime<BR>strTime = "0:32:26"<BR><BR>var NewTimeInSeconds<BR>NewTimeInSeconds = ConvertIntoSecond(strTime)<BR><BR>I&#039;ve RTFM and all I found was.<BR><BR>getSeconds Method<BR>This method returns an integer between 0 and 59 that represents the seconds (local time) for the specified date.<BR>//Devguru.com

2. Kind of lost Guest

## Oh!

I found something here<BR><BR>http://developer.irt.org/script/238.htm

3. Senior Member
Join Date
Dec 1969
Posts
11,334

## RE: Quick question

I don&#039;t think there is a ConvertToTime function.<BR><BR>You can split the string by :, then do your multiplications into seconds as you need to.

4. Senior Member
Join Date
Dec 1969
Posts
758

## write one...

function ConvertIntoSeconds(strTime) {<BR> var temp;<BR> temp = Split(strTime,"&"); //if there is a split func in js<BR> return temp[0]*3600 + temp[1]*60 + temp[2];<BR>}

5. Senior Member
Join Date
Dec 1969
Posts
758

## i meant ":", not "&" (EOP)

.

6. Kind of lost Guest

## Thanks all <eop>.

.

7. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Nope no function

but there is a method :)<BR>

8. Senior Member
Join Date
Dec 1969
Posts
758

## DOH!!! but, what do you mean?

explain.. method vs. function in javascript? so how would i use it?<BR>Thanks.<BR><BR>Jason

9. Senior Member
Join Date
Dec 1969
Posts
11,334

## He's being himself, as usual

;)<BR><BR><BR>Split is a method of a string, not a function<BR><BR>Stringobject.split(delimiter);<BR>

10. Senior Member
Join Date
Dec 1969
Posts
758

## Of course, DOH!!!! again *SMACK* (EOP)

.

#### Posting Permissions

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