Difference between revisions of "Os.time"

From ComputerCraft Wiki
Jump to: navigation, search
m (Updated references from "os" to "OS")
m (Added float tag)
Line 2: Line 2:
 
{{Function
 
{{Function
 
|name=os.time
 
|name=os.time
|returns=The current in-game time.
+
|returns=[[Float_(type)|float]] The current in-game time.
 
|api=OS
 
|api=OS
 
|addon=ComputerCraft
 
|addon=ComputerCraft

Revision as of 21:05, 3 June 2013


Grid Redstone.png  Function os.time
Returns the current in-game time.
Syntax os.time()
Returns float The current in-game time.
Part of ComputerCraft
API OS

Examples

Grid paper.png  Example
Prints current time in 12 hour format (with AM and PM).
Code
local time = os.time()
time = textutils.formatTime(time, false)
print("The time is "..time)



Grid paper.png  Example
Prints current time in 24 hour format.
Code
local time = os.time()
time = textutils.formatTime(time, true)
print("The time is "..time)

Additional Notes

  • You must use textutils.formatTime() if you want to print the time in readable form.