Hello,
I am working on a function that converts seconds to time:
Code
FUNC string SecondtoTime(num s)
VAR num seconds:=0;
VAR num minutes:=0;
VAR num hours:=0;
s:=Round(s);
IF s>=60 THEN
minutes:= s DIV 60;
seconds:= s MOD 60;
ELSE
seconds:=s;
ENDIF
IF minutes >= 60 THEN
hours:= minutes DIV 60;
minutes:= minutes MOD 60;
ELSE
minutes:=minutes;
ENDIF
RETURN NumToStr(hours,0) + ":" + NumToStr(minutes,0);
ENDFUNC
Display More
The problem I'm having is when you input an amount of seconds that returns minutes that are less than 10, a zero is missing. For example 5:05 PM (18300 seconds) reads as 5:5 instead of 5:05. Is there a RAPID command that allows me to prepend a zero? I've looked through the Technical Reference Manual and can't seem to find anything like this. Thanks for your help.