os.time

From ComputerCraft Wiki
Revision as of 12:29, 20 May 2012 by 82.27.17.154 (Talk) (Created page with "{{lowercase}} {{Function |name=os.time |returns=The current in-game time. |api=os |addon=ComputerCraft |desc=Returns the current in-game time. |examples= {{Example |desc=Print...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Grid Redstone.png  Function os.time
Returns the current in-game time.
Syntax os.time()
Returns 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.