Time of feedback being sent is incorrect out of studio

Okay so this might be confusing but I have a system where users can send feedback they have on my game. It tells you the date and time of when they sent it. The problem I have is with the time. In studio, it shows the correct time of when I sent the feedback as you can see in the screenshot it says 18:11 (6:11 PM in my time)
Screen Shot 2021-06-12 at 6.11.44 PM
Now I will show what it is like out of studio and on the published game
Screen Shot 2021-06-12 at 7.09.35 PM As you can see the hour for some reason is 4 hours ahead in the published version but it is correct in studio. I will also link the script (serverscriptservice) that controls the feedback saving in the GUI and controls the date and time (there is also another script in the GUI that just shows the GUI that shows all the feedback to admins and sets the text of the feedback but I wont link it because I don’t think its necessary)

local feedbackDS = dss:GetDataStore("Feedback")

local feedbackData = {}

local success, errorMessage = pcall(function()
	feedbackData = feedbackDS:GetAsync("List") or {}
end)


local re = game.ReplicatedStorage:WaitForChild("FeedbackRE")


re.OnServerEvent:Connect(function(plr, feedback)


	if string.len(string.gsub(feedback, " ", "")) > 0 then

		local success, errorMessage = pcall(function()
			feedback = game:GetService("TextService"):FilterStringAsync(feedback, plr.UserId)
			feedback = feedback:GetNonChatStringForBroadcastAsync()
		end)


		if success then

			local timeOfFeedback = os.time()
			local plrSent = plr.Name


			table.insert(feedbackData, {plrSent, feedback, timeOfFeedback})

			local success, err = pcall(function()

				feedbackDS:SetAsync("List", feedbackData)
			end)
		end
	end
end)


while wait(5) do

	local success, errorMessage = pcall(function()
		feedbackData = feedbackDS:GetAsync("List") or {}
	end)


	game.ReplicatedStorage:WaitForChild("FeedbackFolder"):ClearAllChildren()


	for i, feedbackInfo in pairs(feedbackData) do

		local plrName = feedbackInfo[1]
		local feedback = feedbackInfo[2]
		local timeSent = feedbackInfo[3]

		local timeValues = os.date("*t", timeSent)
		local formattedTime = timeValues["hour"] .. ":" ..  timeValues["min"] .. ":" .. timeValues["sec"]
		local formattedDate = timeValues["month"] .. "/" .. timeValues["day"] .. "/" .. timeValues["year"]
		local combinedTime = formattedTime .. "  " .. formattedDate


		local str = Instance.new("StringValue")
		str.Name = plrName .. " - " .. combinedTime
		str.Value = feedback

		str.Parent = game.ReplicatedStorage.FeedbackFolder
	end
end

Is there any way to fix this because it’s kind of weird how it works in studio but not the regular published game

1 Like