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 269 views
269 views asked Sep 24, 2020 by avibootz
1 answer 249 views
1 answer 252 views
1 answer 182 views
182 views asked Feb 15, 2023 by avibootz
1 answer 239 views
239 views asked Sep 26, 2020 by avibootz
1 answer 265 views
265 views asked Sep 24, 2020 by avibootz
...