This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
dasangrypanda's profile picture

Show Date or Time at startup

Started by dasangrypanda, 10 May 2012 - 06:39 PM
dasangrypanda #1
Posted 10 May 2012 - 08:39 PM
How can I show the time or date at the startup of the computer, minecraft time or real world?

For example when the terminal starts up, i'd like it to look something like this:

Welcome User, The Current Time Is: (clock or date)
Luanub #2
Posted 10 May 2012 - 10:16 PM
You can use os.time() which will return the Minecraft time. As far as I know vanilla CC will not display the real time.
PixelToast #3
Posted 14 May 2012 - 01:01 AM
you can either put this in a startup file or the shell itself, it also makes it the standard time format


a=math.floor(os.time())
b=math.floor((os.time()-a)*60)
if a > 11 then c="PM" a=a-12 else c="AM" end
if b < 10 then b="0"..b end
if a==0 then a=12 end
print("Welcome User, The Current Time Is: "..a..":"..b.." "..c)
-- mormons
MysticT #4
Posted 14 May 2012 - 01:18 AM
you can either put this in a startup file or the shell itself, it also makes it the standard time format


a=math.floor(os.time())
b=math.floor((os.time()-a)*60)
if a > 11 then c="PM" a=a-12 else c="AM" end
if b < 10 then b="0"..b end
if a==0 then a=12 end
print("Welcome User, The Current Time Is: "..a..":"..b.." "..c)
-- mormons
It's easier to use textutils.formatTime():

print("Welcome User")
print("The current time is: ", textutils.formatTime(os.time(), true))