Account join year fix

hey i am trying to do simple code that will show in the leaderboard join year of the player, i got stuck with it

        local joinYear ="%Y", player.AccountAge)
	print(player.Name .. " joined in " .. joinYear)

for some reason i get “joined in 1970”

Try printing just player.AccountAge

its not printing the year, its printing for example:

i joined 2016 and what i got is: “2649” i want to get the “2016”

Its printing the account age, not the date of join. That number is how days that user has been on the platform. So getting the current day - AccountAge, which give you the day they joined. So try using some math to figure out what year it is.

1 Like

yes thats what i am asking for help, i tried all i know

2649 is the days, first you need to divide it by 365, which in return will be 7.25…, then use math.round and then you subtract the current year with the number (7 in this case). And the number you get, in this example, 2023 - 7 is 2016.

And if you want a script, something like this:

	local date ="*t")
	print(date) -- prints the table, you can check what things you can get
	local year = date["year"] -- the year
	local playerDays = player.AccountAge
	local subtractNumber = playerDays / 365
	local roundSubtractNumber = math.round(subtractNumber)
	local playerAge = year - roundSubtractNumber
	print(player.Name .. " joined in ".. playerAge)
1 Like

you should probably familiarise yourself with how timestamps work
if you want 100% accuracy then you should use the apis and not divide the account age by 365 because that could have false flags if a leap year is involved (now that i think about it, it’s very unlikely to cause an issue but it’s still a probability and i prefer accuracy :rage:)

but since roblox is TOO PARANOID and doesn’t let you use their apis in-game (although they should just use unauthenticated requests but whatever), you’d have to use a proxy such as and extract the ‘created’ field


you can simply accomplish this by doing this

local HttpService = game:GetService("HttpService")

	local success, response = pcall(function()
		return HttpService:JSONDecode(HttpService:GetAsync("" .. player.UserId))
	if success and response ~= nil then
		local joinYear = string.split(response.created, "-")[1]
		print(player.Name .. " joined in " .. joinYear)
		print("something went wrong. try enabling HTTP requests")

omg it’s functional!!

local currDay = math.floor(tick() / 86400) -- 60 * 60 * 24
local joinDate = currDay - player.AccountAge

joinDate will be the amount of days after January 1st, 1970