This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

time in lua
#1
Hi,

I have a device it which returns a time stamp,  in the follow format:   1552587707032


Now I need to send the current time back in the same format.  os.time generates a time like 1552589984  which is 3 digits less that what the device is expecting.  Does anybody have an idea how to get the same format?

Thanks,

Roger
Reply
#2
Hi Roger,

I think it's a UNIX microtime format with milliseconds included.

I would try to do this to make it os.time() format (seconds):

Code:
value = 1552587707032
value = math.floor((value/1000))
log(value) --> 1552587707

BR,

Erwin
Reply
#3
ok, how would I send the time back in that format? just multiply by a 1000
Reply
#4
Code:
ts, tu = os.microtime()
time = ts * 1000 + math.floor(tu / 1000)
Reply
#5
Hi, thank you that works...

Thx
Roger
Reply


Forum Jump: