How to get the current IRL time?

So currently at GMT+1 it’s 19:44 PM and I have a webhook that logs when a moderator joined, the script works but I want it to also say “Moderator cmodii logged on XX:XX AM/PM”
Here is the script:

local modlogger = "url"
local http = game:GetService("HttpService")

-- For when moderator joins:

if plr.Name == "cmodii" then
    local data = {
        ["embeds"] = {
                ["title"] = "**Moderator Logged on**", -- what are we logging
                ["description"] = "Moderator "..plr.Name.." has logged on." -- i want the time to be here such as Moderator cmodii has logged on 19:45 PM GMT+1
    local finaldata = http:JSONEncode(data)
    http:PostAsync(modlogger, finaldata)

Thanks in advance!


Take a look at this and if u still got other questions for this than dont ask me.

1 Like

As the person above stated. Use the os to code your IRL time script. Should work since it’s a simple task.

Using os.time

local TIME_ZONE = 1

local date ="!*t")
local hour = (date.hour + TIME_ZONE) % 24
local ampm = hour < 12 and "AM" or "PM"
local timestamp = string.format("%02i:%02i %s", ((hour - 1) % 12) + 1, date.min, ampm)


Thank you, however I found out how to do it, still this is better for timezone and AM/PM checking, my solution was this:

local hours ="*t")["hour"] -- for hour irl
local mins ="*t")["min"] -- for min irl

I added the timezone check because calling os.time with !*t as the parameter uses GMT, while *t makes it use the local time on the machine that runs the code. It might be better to define the timestamp in the script since in an online game the server code will be running on Roblox’s servers, causing it to return their local time, which may be different from yours.


Ah alright got it, thanks man appreciate it!

You can also implement a timestamp (add new index called timestamp in embed dictionary) if you’d like for precise time that looks just like the time a Discord message has (e.g. Today at 9:01 AM) using this if you want: