Question by 
               mealone · Oct 11, 2015 at 12:44 AM · 
                scripting problemscript.codepage  
              
 
              need help with simple timing code
Hi guys! This is the code that i have on the timer script. It works up to the minutes, but I am trying to figure out how to add hours and days to it. I really need help with this. can anyone figure this out? here is the code:
 function Timing()
  {
      if (timer > 0) {
          
            hourdisplay = parseInt( (timer / 60)/ 60 ).ToString();
      
          
          minsDisplay = parseInt( timer / 60 ).ToString();
          
         
          secsDisplay = parseInt( timer ).ToString();
           
          if ( (timer - ( parseInt(minsDisplay) * 60)) > 10 ) {
               secsDisplay = parseInt( timer - ( parseInt(minsDisplay) * 60) ).ToString();
          } 
          else {
              secsDisplay = "0" + parseInt( timer - ( parseInt(minsDisplay) * 60) ).ToString();
          }
          
         
      } 
      else {
           timer += timer;
      }
      displayText.text = minsDisplay + " : " + secsDisplay;
  }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Mako-Infused · Oct 11, 2015 at 01:43 AM
If you want to display seconds, minutes, hours, and days separately (in their own variable) use something like this:
 daysdisplay = parseInt( timer / 60 / 60 / 24 ).ToString();
 hourdisplay = parseInt( timer / 60 / 60 % 24 ).ToString();
 minsDisplay = parseInt( timer / 60 % 60 ).ToString();
 secsDisplay = parseInt( timer % 60).ToString();
Hope that helps!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                