Reputation: 11
so I have been toying around with this analog clock, and I've attempted to find the answers online but found none. What I basically want this clock to do is pretty much reference GMT time and not the time on my computer because I am trying to make a game that shows all the times in the world. But I cannot do that because if I added 6 hours to show German time, it would correctly tell the time for me, but it would not for anyone in a different time zone. What should I change in my code?
local sp = script.Parent
local Clock = sp.Clock
local HourArrow = Clock.Hour
local MinArrow = Clock.Min
SecArrow = Clock.Sec
while true do
local t=tick()
local hour=(((t/60)/60)/12)%1
local minute=(hour*12)%1
local mint = math.floor(minute*60)
local second= math.floor(((minute*60)%1)*60)
HourArrow.Rotation = 180+(hour*360)
MinArrow.Rotation = 180+(mint*6)
SecArrow.Rotation = 180+(second*6)
wait(1)
end
Upvotes: 1
Views: 626
Reputation: 422
Your current script is unnecessary.
myTime = os.time{year=1970,month=1,day=1,hour=0} --current time in seconds from jan 1 1970 midnight
hoursToMove = 1 --how many hours to move forward
myTime = hoursToMove*60*60 + myTime --multiplies by 60 twice to reach minutes then hours
myTime
would now equal the number of seconds passed since January 1, 1970, 00:00
UTC, plus one hour - change hoursToMove
to modify how many hours forwards/backwards you want (negative numbers would work).
Upvotes: 1
Reputation: 1
You should use "os.date("!%c")" to print UTC time directly, or "os.time()" to get seconds passed from 1 January 1970, 00:00:00 (UTC)
sources : StackOverflow, Roblox time, Roblox date
Upvotes: 0