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 283 views
283 views asked Sep 24, 2020 by avibootz
1 answer 266 views
1 answer 263 views
1 answer 190 views
190 views asked Feb 15, 2023 by avibootz
1 answer 252 views
252 views asked Sep 26, 2020 by avibootz
1 answer 273 views
273 views asked Sep 24, 2020 by avibootz
...