Garry's Mod Wiki

string.FormattedTime

  string string.FormattedTime( number float, string format = nil )

Description

Returns the time as a formatted string or as a table if no format is given.

Arguments

1 number float
The time in seconds to format.
2 string format = nil
An optional formatting to use. If no format it specified, a table will be returned instead.

Returns

1 string
Returns the time as a formatted string only if a format was specified.

Returns a table only if no format was specified. The table will contain these fields:

Example

Formats the time in seconds

local time = string.FormattedTime( 90, "%02i:%02i:%02i" ) print( time )
Output: 01:30:00

Example

Returns a table with the time separated by units.

local time = string.FormattedTime( 90 ) PrintTable( time )
Output:
ms = 0 m = 1 s = 30 h = 0