View Full Version : Calculating Seconds from 1:23
voterone
04-28-2003, 05:31 PM
I run a program that collects song length from an mp3 then posts that info to a html file as min:sec.
Is it possible to calculate total seconds from min:sec? ex: 1:23 = 83.
Thanks
beetle
04-28-2003, 05:40 PM
String.prototype.toSeconds = function()
{
var time = this.split( ":" );
return parseInt( time[0], 10) * 60 + parseInt( time[1], 10 );
}
var myTime = "1:23";
alert( myTime.toSeconds() );
voterone
04-28-2003, 09:24 PM
Thanks so much for the reply.
Here's what I have;
var refreshpl;
refreshpl = %%SONGLENGTH%%;
String.prototype.toSeconds = function()
{
var refreshpl = this.split( ":" );
return parseInt( time[0], 10) * 60 + parseInt( time[1], 10 );
}
My task; Grab the time from an mp3 (%%SONGLENGTH%%), pass that info to an html file (playlist.html). In playlist.html I have a Meta Refresh tag (meta http-equiv="Refresh" content="%%SONGLENGTH%%; URL=SOMEURL").
When playlist.html is accessed, the above javascript needs to supply %%SONGLENGTH%% in the Meta tag the recalculated and parsed info. Is that possible? I can't seem to wrap my head around this task.
Thanks
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.