Return to Snippet

Revision: 36258
at November 20, 2010 00:45 by withinmedianl


Initial Code
private function convertTime(secs:Number, format:String = ""):String
		{
			var toReturn:String;
			
			var h:Number=Math.floor(secs/3600);
			var m:Number=Math.floor((secs%3600)/60);
			var s:Number=Math.floor((secs%3600)%60);
			if (format)
			{
				if(format == "h")
				{
					toReturn = (h==0?"":(h<10?"0"+h.toString()+":":h.toString()));
				}
				else if(format == "m")
				{
					toReturn = ((m<10?"0"+m.toString():m.toString()));
				}
				else if(format == "s")
				{
					toReturn = ((s<10?"0"+s.toString():s.toString()));
				}
			}
			else
			{
				toReturn = (h==0?"":(h<10?"0"+h.toString()+":":h.toString()+":"))+(m<10?"0"+m.toString():m.toString())+":"+(s<10?"0"+s.toString():s.toString());
			}
			return toReturn;
		}

Initial URL

                                

Initial Description
based on: http://www.snipplr.com/view/33913/actionscript-seconds-to-standard-time-format/

Initial Title
Convert number (time) to more readable time

Initial Tags
convert

Initial Language
ActionScript 3