practice/lua/time/main.lua
2017-05-18 10:17:16 -07:00

16 lines
524 B
Lua

-- Create a table named time to store current time
time = os.date("*t")
-- Old stand by
print (time.year .. "-" .. time.month .. "-" .. time.day)
-- Allow for beter control, seems to print up to 2 decimal places
-- Not actually sure how this works
-- The first number seems to add perceding spaces
-- The second number seems to add perceding 0's
print (("%02d-%02d-%02d"):format(time.year, time.month, time.day))
-- Concat with a deliminator noted at the end
print (table.concat({time.year, time.month, time.day}, "-"))