Difference between revisions of "Os.time"
From ComputerCraft Wiki
(Changing number to number) |
MKlegoman357 (Talk | contribs) m (Fixed/Expanded) |
||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=os.time | |name=os.time | ||
− | |returns={{type|number}} | + | |returns={{type|number}} the current in-game time |
|api=OS | |api=OS | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
Line 9: | Line 9: | ||
{{Example | {{Example | ||
|desc=Prints current time in 12 hour format (with AM and PM). | |desc=Prints current time in 12 hour format (with AM and PM). | ||
− | |code=local time = os.time() | + | |code=local time = '''os.time()''' |
− | + | local formattedTime = [[textutils.formatTime]](time, false) | |
− | + | ||
− | + | [[print]]("The time is " .. formattedTime) | |
− | + | ||
}} | }} | ||
|notes= | |notes= | ||
− | * You | + | * You should use [[textutils.formatTime]]() if you want to print the time in readable form. |
}} | }} | ||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] |
Revision as of 22:38, 3 June 2014
Function os.time | |
Returns the current in-game time. | |
Syntax | os.time() |
Returns | number the current in-game time |
Part of | ComputerCraft |
API | OS |
Examples
Example | |
Prints current time in 12 hour format (with AM and PM). | |
Code |
local time = os.time() local formattedTime = textutils.formatTime(time, false) print("The time is " .. formattedTime) |
Additional Notes
- You should use textutils.formatTime() if you want to print the time in readable form.