Lua - Current time in milliseconds

okoman picture okoman · Jan 20, 2009 · Viewed 120.5k times · Source

Is there a common way to get the current time in or with milliseconds?

There is os.time(), but it only provides full seconds.

Answer

waqas picture waqas · Jan 22, 2009

I use LuaSocket to get more precision.

require "socket"
print("Milliseconds: " .. socket.gettime()*1000)

This adds a dependency of course, but works fine for personal use (in benchmarking scripts for example).