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 276 views
276 views asked Sep 24, 2020 by avibootz
1 answer 255 views
1 answer 257 views
1 answer 186 views
186 views asked Feb 15, 2023 by avibootz
1 answer 247 views
247 views asked Sep 26, 2020 by avibootz
1 answer 267 views
267 views asked Sep 24, 2020 by avibootz
...