How to check if a place's server is up to date / Running latest version

Hello! :wave: This is my first forum post,

I was looking around for a way to check if a game’s server was up to date and was unable to find one. So I made my own and I would like to share it with all of you as I feel that this should not be as hard to find as it was.

https://www.roblox.com/library/9869314549/
The module is parented to a sever script that demonstrates the use of this module

Lastest edit removed the need for http requests

local m = {}

--Made by sakari119 // 91144065
--June 10th 2022 

local upDateTime = 0

--returns true / false
function m:CheckIfUpToDate()
	local uptodate = nil
	local state,err = pcall(function()
		local asset = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
		local update_stamp = tostring(asset.Updated)
		upDateTime = ConvertTimeStampToUnix(update_stamp)
		uptodate = os.time() - upDateTime > time()
	end)
	if not state then
		warn("Update checker:",err)
	end
	return uptodate
end

--returns time in unix seconds
-- use os.time() - m:GetVersionAge() to get time since update
function m:GetVersionAge()
	return os.time() - upDateTime
end

--Gets time when update was made
function m:GetVersionTime()
	return upDateTime
end

--Powered by lua magic
function ConvertTimeStampToUnix(time_stamp) 
	local p="(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)"
	local year,month,day,hour,min,sec=time_stamp:match(p)
	return os.time({day=day,month=month,year=year,hour=hour,min=min,sec=sec})
end

return m
12 Likes

Nice job! I could see this being widely used as an easier way to make custom server shutdown UI.

I just noticed a small bug Imma try fix it today