Input number of seconds, get a string back that shows days, hours, minutes, seconds

From Second Life Wiki
Revision as of 01:09, 1 September 2010 by Fire Centaur (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


  • string getTime(integer seconds)
  • Will return Days, Hours, Minutes
  • /

string getTime(integer secs){

 string timeStr;
 integer days;
 integer hours;
 integer minutes;
 if(secs>=86400){days=llFloor(secs/86400);secs=secs%86400;timeStr=(string)days+" day";
     if(secs>0){timeStr+=", ";}
 if(secs>=3600){hours=llFloor(secs/3600);secs=secs%3600;timeStr+=(string)hours+" hour";if(hours!=1){timeStr+="s";}
     if(secs>0){timeStr+=", ";}}
 if(secs>=60){minutes=llFloor(secs/60);secs=secs%60;timeStr+=(string)minutes+" minute";if(minutes!=1){timeStr+="s";}if(secs>0){timeStr+=", ";}}
 timeStr+=(string)secs+" second";if(secs!=1){timeStr+="s";}
 return timeStr;