How to get the current date and time with milliseconds in Lua

1 Answer

0 votes
local dt = os.date("*t")

local ms = string.match(tostring(os.clock()), "%d%.(%d+)")

local d = string.format("%d-%d-%d %d:%d:%d:%s", dt.year, dt.month, dt.wday, dt.hour, dt.min, dt.sec, ms)

print(d)



--[[
run:
  
2020-9-6 13:56:21:002503
 
--]]

 



answered Sep 25, 2020 by avibootz
edited Sep 25, 2020 by avibootz

Related questions

1 answer 372 views
372 views asked Sep 24, 2020 by avibootz
1 answer 357 views
1 answer 364 views
1 answer 282 views
282 views asked Feb 15, 2023 by avibootz
1 answer 349 views
349 views asked Sep 26, 2020 by avibootz
1 answer 362 views
362 views asked Sep 24, 2020 by avibootz
...