Difference between revisions of "Textutils.formatTime"

From ComputerCraft Wiki
Jump to: navigation, search
m (Moved to CAT:APIFunctions)
(Changing int to number)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=textutils.formatTime
 
|name=textutils.formatTime
|args= [[float (type)|float]] time, [[boolean (type)|boolean]] isTwentyFourHour
+
|args= {{type|number}} time, {{type|boolean}} isTwentyFourHour
|returns=[[string (type)|string]] formatted time
+
|returns={{type|string}} formatted time
 
|api=textutils
 
|api=textutils
 
|addon=ComputerCraft
 
|addon=ComputerCraft

Revision as of 12:56, 18 July 2013


Grid Redstone.png  Function textutils.formatTime
Formats a time that is in float format.
Syntax textutils.formatTime(number time, boolean isTwentyFourHour)
Returns string formatted time
Part of ComputerCraft
API textutils

Examples

Grid paper.png  Example
Prints the Minecraft world time in 12-hour time.
Code
print(textutils.formatTime(os.time(), false))
Output Depends on the time of day in your world, it will look something like this: "5:30 AM".




Grid paper.png  Example
Prints the Minecraft world time in 24-hour time.
Code
print(textutils.formatTime(os.time(), true))
Output Depends on the time of day in your world, it will look something like this: "17:30".