Game Dev Guide

Roblox & Real-World Time

Want to make your Roblox game mimic the real world? Use the `HttpService` in Lua to fetch the current time for a specific timezone and synchronize your game's lighting or events.

Implementation example

LUA
local HttpService = game:GetService("HttpService")

local function getRealTime()
    local url = "https://sunrise.am/developer/api/timezone/America/New_York"

    local success, response = pcall(function()
        return HttpService:GetAsync(url)
    end)

    if success then
        local data = HttpService:JSONDecode(response)
        print("NYC Time: " .. data.datetime)
        return data
    else
        warn("Failed to fetch time")
    end
end

-- Run function
getRealTime()

Why use Sunrise.am for Game Dev?

  • Sync Day/Night cycles
  • Live in-game events
  • Easy JSON decoding
API Reference View All Guides