Garry's Mod Wiki

Revision Difference

string.FormattedTime#512005

<function name="FormattedTime" parent="string" type="libraryfunc">⤶ <description>Returns the time as a formatted string or as a table if no format is given.</description>⤶ <realm>Shared and Menu</realm>⤶ <file line="166">lua/includes/extensions/string.lua</file>⤶ <args>⤶ <arg name="float" type="number">The time in seconds to format.</arg>⤶ <arg name="format" type="string" default="nil">An optional formatting to use. If no format it specified, a table will be returned instead.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="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:⤶ ⤶ ⤶ <page>number</page> ms - milliseconds⤶ ⤶ ⤶ <page>number</page> s - seconds⤶ ⤶ ⤶ <page>number</page> m - minutes⤶ ⤶ ⤶ <page>number</page> h - hours</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Formats the time in seconds</description>⤶ <code>⤶ local time = string.FormattedTime( 90, "%02i:%02i:%02i" )⤶ print( time )⤶ </code>⤶ <output>01:30:00</output>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>Returns a table with the time separated by units.</description>⤶ <code>⤶ local time = string.FormattedTime( 90 )⤶ PrintTable( time )⤶ </code>⤶ <output>⤶ &amp;lt;br&amp;gt;ms = 0&amp;lt;br&amp;gt;⤶ m = 1&amp;lt;br&amp;gt;⤶ s = 30&amp;lt;br&amp;gt;⤶ h = 0&amp;lt;br&amp;gt;⤶ </output>⤶ ⤶ </example>