The error handling table generated by the os.time () Lua command

table.concat(os.date("*t"), ":",4,6)

any idea why this ^ or this

test = os.date("*t")
table.concat(test, ":" , 4 , 6 )

does not work?

input: 3: invalid value (nil) at index 4 in table for 'concat'

+4
source share
2 answers

table.concatworks with a numerical indexed table. While the output os.date '*t'will be table, for example :

hour    18
min 20
wday    1
day 2
month   3
year    2014
sec 49
yday    61
isdst   false
+3
source

Although not the answer to your direct question, I suspect that you are trying to do this in order to get the time separated by colons.

The best way to do this is os.date"%H:%M:%S"

The formatting options are very flexible and use the strftime C. format .

0
source

Source: https://habr.com/ru/post/1529677/


All Articles