|
Post by zenkrye on Jan 1, 2018 21:56:27 GMT
Can someone help shed some light on getNetworkTime() for me? I am trying to convert the return of long integer to an military time. I want to be able to check the network time and if it is after a specific time that the server does resets, reset my actions.
I have tried using it with the code below but obviously this is not working. I am guessing that the return includes date along with the time.
function SecondsToClock(seconds)
local seconds = tonumber(seconds)
if seconds <= 0 then
return "00:00:00";
else
local hours = string.format("%02.f", math.floor(seconds/3600));
local mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
local secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
return hours..":"..mins..":"..secs
end
end
|
|
|
Post by AnkuLua on Jan 1, 2018 23:57:17 GMT
Use os.date() www.lua.org/pil/22.1.htmlFor example, to get the hour and minute in 24-hour clock os.date("%H%M") Note: the return value is string. You can convert it to number by t = 0 + os.date("%H%M")
|
|