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:
game.Players.PlayerAdded:Connect(function(plr)
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)
end
end)
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.
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:
Seems like this became the top result for this topic when googled, just wanted to update this with refurbished code that uses mod 24 instead of 12
local TIME_ZONE = 1
local date = os.date("!*t")
local hour = (date.hour + TIME_ZONE) % 24
local timestamp = string.format("%02i:%02i", hour, date.min)
print(timestamp)