JS把给定的秒数解析成 时 分 秒 格式

function parseSecond(seconds)
{	
	 var parseTime = seconds;
	 //seconde
	 if(parseTime<60)				   
		 parseTime +=" 秒";
	 //minute
	 else if(parseTime >= 60 && parseTime<3600)
	 {
		  var minute = parseTime/60+"";
		  if(minute.indexOf(".") != -1)
		  {
			 minute = minute.substr(0,minute.indexOf("."));			 
		  }								
		  var second = parseTime - 60*parseInt(minute);				
		  parseTime = minute+"分";
		  parseTime += second+"秒";
		  
	 }
	 //hour
	 else if(parseTime>=3600)
	 {
	   var hour = parseTime/3600+"";
	   if(hour.indexOf(".") != -1)
	   {
		 hour = hour.substr(0,hour.indexOf("."));   
	   }		 
	   var minute = parseTime - 3600*parseInt(hour);					 	 
		   minute = (parseTime - 3600*parseInt(hour))/60+"";
	  if(minute.indexOf(".")!=-1)
	  {
		   minute = minute.substr(0,minute.indexOf("."));
	  }		  
		
	   var second = ((parseTime - 3600*parseInt(hour))) - 60*parseInt(minute);					
	   
	   parseTime = hour+"时";
	   parseTime += minute+"分";
	   parseTime += second+"秒"; 	   
	   
	   }
	 
	   return parseTime;	
}


你可能感兴趣的:(js,js)