Time Function

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Time Function

Post by Jeff Barnes »

Hi Everybody,

Is there a function to convert seconds to a time format like HH:MM:SS ?

Exanple:

nSeconds = 3600

something like SecondsToTime( nSeconds ) would return "01:00:00"


Thanks,
Jeff
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Time Function

Post by Enrico Maria Giordano »

Code: Select all

FUNCTION MAIN()

    LOCAL nSec := SECONDS()

    ? nSec, SECONDSTOTIME( nSec )

    INKEY( 0 )

    RETURN NIL


STATIC FUNCTION SECONDSTOTIME( nSec )

    LOCAL nHour, nMin

    nHour = INT( nSec / 3600 )

    nSec -= nHour * 3600

    nMin = INT( nSec / 60 )

    nSec -= nMin * 60

    RETURN STRZERO( nHour, 2 ) + ":" + STRZERO( nMin, 2 ) + ":" + STRZERO( nSec, 2 )
EMG
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Exactly what I needed :D

Thanks Enrico.


Jeff
Post Reply