title: Trying to make a reusable function and display the result in a div
body: <p>I have this function that I am trying to work with. All I am trying to do is to get the values of days, hours, min and sec into the .overTime div. I want to use the same function over and over again because i have more divs in which I want to display the same values but in a diff manner.</p>
  
  <p>You guys are awesome Thank You.</p>
  
  <pre><code>    NowTime = new Date(); //Time Now
  StartTime = new Date($('#StartTime').val());
  StopTime = new Date($('#StopTime').val());
  
  function fixIntegers(integer){
      if (integer &lt; 0)
          integer = 0;
      if (integer &lt; 10)
          return '0' + integer;
      return '' + integer;
  }  
      function Test( difference )
      {
          var toReturn = { days: 0, hours: 0, minutes: 0, seconds: 0 };
          toReturn.seconds = fixIntegers(difference % 60);
          difference = Math.floor(difference / 60);    
  
          toReturn.minutes = fixIntegers(difference % 60);
          difference = Math.floor(difference / 60);
  
          toReturn.hours = fixIntegers(difference % 24);
          difference = Math.floor(difference / 24);
  
          toReturn.days = fixIntegers(difference);
          return toReturn;
      }
  
      function run()
      {
          var output = Test( Math.floor( ( NowTime - StopTime ) / 1000 ) );
          $('.OverTime').html( output.days + ':' + output.hours + ':' + output.minutes + ':' + seconds);
      }
  setInterval(run, 1000)
  </code></pre>
  
  <p>FIDDLE: <a href="http://jsfiddle.net/8943U/47/" rel="nofollow">http://jsfiddle.net/8943U/47/</a></p>