Returns a description of an amount of time in appropriate units. Output includes markup normally hidden when displayed in a FontString (see last example); this markup allows the client to automatically print the singular or plural form of a word depending on the value of the preceding number.


See also Utility functions.

Signature:

time = SecondsToTime(seconds [, noSeconds [, notAbbreviated [, maxCount]]])

Arguments:

  • seconds - An amount of time (in seconds) (number)
  • noSeconds - True to omit a seconds term in the description; false or omitted otherwise (boolean)
  • notAbbreviated - True to use full unit names in the description (e.g. Hours, Minutes); false or omitted to use abbreviations (e.g. Hr, Min) (boolean)
  • maxCount - Maximum number of terms to include in the description; defaults to 2 if omitted (number)

Returns:

  • time - A description of the amount of time in appropriate units (see examples) (string)

Examples:

print(SecondsToTime(100))
-- shows "1 Min 40 Sec"

print(SecondsToTime(100, true))
-- shows "1 Min"

print(SecondsToTime(10000))
-- shows "2 Hr 46 Min"

print(SecondsToTime(10000, false, true))
-- shows "2 Hours 46 Minutes"

print(SecondsToTime(100000, false, false, 5))
-- shows "1 Day 3 Hr 46 Min 40 Sec"

SecondsToTime(100, false, true)
-- returns "1 |4Minute:Minutes; 40 |4Second:Seconds;"
This function is not a C API but a Lua function declared in Blizzard's default user interface. Its implementation can be viewed by extracting the addon data using the Addon Kit provided by Blizzard.
This function is defined by the default user interface in Lua. You can find the definition by examining the FrameXML code for the default UI,