Converts seconds into a time string


      SecToTime(<nSeconds>, [<lHundredth>]) --> cTime


<nSeconds> Designates the number of seconds since midnight to convert into a character string in time format.

<lHundredth> If this optional parameter is designated as .T., the resulting time string contains hundredths of seconds. The default is no hundredths (.F.).


SecToTime() returns a time string that corresponds to <nSeconds> in the “HH:MM:SS” or “HH:MM:SS:hh” format.


This function can be applied in two areas — to convert numeric time spans in seconds, and to convert a point in time into the “HH:MM:SS” or “HH:MM:SS:hh” format.

If hundredths of seconds are also desired in the time string result, then designate the second parameter as .T.. The portion of the value for <nSeconds> to the right of the decimal is also converted.


. Seconds since midnight are in the range of 0 to 86400. With larger values, the function internally executes the operation <nSeconds> % 86400 and then uses the result value. 86400 seconds corresponds to an entire day.

. There is no rounding when values like 45366.98 are converted without hundredths.


      .  Calculate the span between two times.  The result is displayed
         in the "HH:MM:SS" format:

      nBeginning  :=  170
      nEnd        :=  3656

      ? SECTOTIME(nEnd - nBeginning)     // "00:58:06"

      .  With hundredth seconds:

      ? SECTOTIME(45873.22, .T.)         // "12:44:33:22"



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.