Does Roblox track timezones?

First of all, yes, I’ve looked at other posts about this, but they all just seem to have links going to the os page on the DevHub. I am interested in knowing if Roblox stores timezones based on location when you join the game, and how I could find the time zone in a script. If there is no way to do this, would the best way be to ask the players for their timezone?

1 Like

Yes. I’m not sure if directly, but they certainly do it indirectly. You can get a player’s region code. (Which can be spoofed… but who cares enough to do that?)

https://developer.roblox.com/en-us/api-reference/function/LocalizationService/GetCountryRegionForPlayerAsync

You can also just have the client tell you their current time via a remote event.

The tick function returning a timestamp being a local time for the player’s computer.

1 Like

@SwagMasterAndrew Okay, but doesn’t the US have multiple timezones? I looked at the GetCountryRegionForPlayerAsync link and just found the broad “US”

Not that I’m making a clock system for anything important, but I’d like to have it be automatic

The most you can do is get the difference in hours and minutes between the client’s time on their device, using tick() and the current time in the UTC / GMT timezone, using os.time. You can refer to a table which holds the difference in hours and minutes as the key and name of the timezone as the value.

Example

local timezones = {
    [-4] = "EST", -- Eastern standard time
    [-7] = "MST", -- Mountain standard time
    [10.5] = "ACDT", -- Australian Central Daylight Time
    [11] = "AEDT" -- Australian Eastern Daylight Time
    [0] = "GMT" -- or UTC
}
local time_offset = (math.floor(tick()) - os.time()) / 3600
local timezone = timezones[time_offset] or "GMT" .. (time_offset > 0 and "+" or "") .. time_offset  

This is only an approximation – you also have to consider daylight savings time and the continents that observe it. The client also has the ability to change their time at their discretion

2 Likes