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 194 views
194 views asked Sep 24, 2020 by avibootz
1 answer 177 views
2 answers 139 views
1 answer 181 views
1 answer 101 views
101 views asked Feb 15, 2023 by avibootz
...