Jump to content

HELP TIME SYSTEM


Recommended Posts

hii there , i am from indonesian , but this time is US Time maybe ,,, how to set the time same as my country time ?

For example ,, this script show time : 18:00 ,,, but in my country the time is 09:00 ,, how to set US time - 12 hours , so

18:00 - 12 hours = 09:00

Here is the script :)

  
function updateTime() 
    local offset = tonumber(get("offset")) or 0 
    local realtime = getRealTime() 
    hour = realtime.hour + offset  
    if hour >= 24 then 
        hour = hour - 24 
    elseif hour < 0 then 
        hour = hour + 24 
    end 
  
    minute = realtime.minute 
  
    setTime(hour, minute)  
  
    nextupdate = (60-realtime.second) * 1000 
    setMinuteDuration( nextupdate ) 
    setTimer( setMinuteDuration, nextupdate + 5, 1, 60000 ) 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(), updateTime ) 
  
-- update the time every 30 minutes (correction) 
setTimer( updateTime, 1800000, 0 ) 
  

Link to comment

The getRealTime function has the current time in seconds as default argument, so you could add or subtract the amount of seconds needed to convert into your own time zone by some basic math:

local offset = 3600 * <amount_of_hours> 
local realTime = getRealTime() 
local current = realTime.timestamp 
local localTime = getRealTime(current + offset) 

Link to comment

So i must to edit this script like this ...???

  
function updateTime() 
    local offset = 3600 * 9 
    local realtime = getRealTime() 
    hour = realtime.hour - offset 
    if hour >= 24 then 
        hour = hour - 24 
    elseif hour < 0 then 
        hour = hour + 24 
    end 
  
    minute = realtime.minute 
  
    setTime(hour, minute) 
  
    nextupdate = (60-realtime.second) * 1000 
    setMinuteDuration( nextupdate ) 
    setTimer( setMinuteDuration, nextupdate + 5, 1, 60000 ) 
end 
  
addEventHandler("onResourceStart", getResourceRootElement(), updateTime ) 
  
-- update the time every 30 minutes (correction) 
setTimer( updateTime, 1800000, 0 ) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...