Difference between revisions of "Textutils.formatTime"

From ComputerCraft Wiki
Jump to: navigation, search
Line 10: Line 10:
 
{{Example
 
{{Example
 
|desc=Prints the Minecraft world time in 12-hour time.
 
|desc=Prints the Minecraft world time in 12-hour time.
|code=print(textutils.formatTime(os.clock(), false))
+
|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".
 
|output=Depends on the time of day in your world, it will look something like this: "5:30 AM".
 
}}
 
}}
Line 16: Line 16:
 
{{Example
 
{{Example
 
|desc=Prints the Minecraft world time in 24-hour time.
 
|desc=Prints the Minecraft world time in 24-hour time.
|code=print(textutils.formatTime(os.clock(), true))
+
|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".
 
|output=Depends on the time of day in your world, it will look something like this: "17:30".
 
}}
 
}}
 
}}
 
}}

Revision as of 09:39, 27 October 2012


Grid Redstone.png  Function textutils.formatTime
Formats a time that is in float format.
Syntax textutils.formatTime(float 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".