Here is a snippet of my code:

		if (parts[0] == "time"){
			var t = document.getElementById("time");
			var timeleft=parts[1];
			if(timeleft<0)
			{
				timeleft=0;
			}
			t.innerHTML = timeleft;
			t=null;
		}

timeleft is currently displayer in seconds like this: 94

I would like to display this as 1:34 (1 min, 34 sec)

Any help would be appreciated

    This is what I came up with (with my admittedly shaky JavaScript skills):

    <script type="text/javascript">
    var timeInSeconds = 146; // value to be displayed
    var dt = new Date();
    dt.setTime(timeInSeconds * 1000);
    var minutes = dt.getMinutes();
    var seconds = dt.getSeconds();
    if(minutes < 10)
    {
       document.write("0");
    }
    document.write(minutes + ":");
    if(seconds < 10)
    {
       document.write("0");
    }
    document.write(seconds);
    </script>
    

      I'd be more inclined to write a function that just does the conversion....

      function seconds_to_mmss(sec)
      {
          var ss = sec%60;
          var mm = (sec-ss)/60;
      
      if(ss<10) ss = "0"+ss;
      return mm+":"+ss;
      }
      

      ...and figure out what to do with it later.

        Write a Reply...