Home > Enterprise >  How to get milliseconds with the date and time using Lua script
How to get milliseconds with the date and time using Lua script

Time:08-16

I am trying to get milliseconds with the Lua date time This is how I am getting os time.

time = os.date("%Y-%m-%d %H:%M:%S")

which returns me the date and time as 2022-08-15 08:30:40 I also want to add milliseconds(00 to 999) with it like the expected output is 2022-08-15 08:30:40.786

I tried to find it but had no success even here at Lua date time page there is no info about this https://www.lua.org/pil/22.1.html

Any help would be appreciated, Thanks

CodePudding user response:

It is impossible to get sub-second time resolution by using os.date.
os.date internally invokes C function strftime which does not have fractional seconds data field in the data structure it's working with.

  • Related