# Is there an API to know if it's a player's join anniversary?

Not sure if there’s a method I could call to find this information out or something.

Help appreciated, thanks!

1 Like

There is `player.AccountAge`, which tells you the age of their account in days. For legal reasons you can’t get their birthday if you were wondering.

2 Likes

Continuing off of what @incapaxx said, you can divide `player.AccountAge` by the average number of days in a year (about 365) and check if the remainder is equal to 0:

``````local player=game.Players.LocalPlayer
local age=player.AccountAge
if age%365==0 then --get remainder of age divided by 365
--anniversary, do stuff
end
``````

There’s leap days and whatever to figure out, but honestly if the anniversary is off by a day or two the player probably isn’t going to notice.

2 Likes

On the issue of leap days, and such you can use the `os.date` function.

First you have this lovely `AccountAge` property of a player. You can use this number and subtract if from the current timestamp (make sure you’re in the same unit, don’t try to subtract days from seconds :|)

There are 60 seconds in a minute and 60 minutes in an hour and 24 hours in a day therefore the amount of seconds in a day is `60 * 60 * 24 = 86400`. Using this you can take the amount of seconds in `x` days;
`x * 86400`

You can subtract this number from the current time stamp. `tick() - (x * 86400)` and then pass that number to `os.date` which will return a number. If the current date of today is equal to the current date of the time stamp from when they joined then it is their anniversary!!

4 Likes

I could be wrong, but didn’t you make a post on the same topic of a person join date and checking if it matches? If it’s the same thing then you have a solution already, if not please correct me.

1 Like

to add on once more, you might want to check if their age is > 0 if this is for like a reward, since a player can use an alt since new accounts would have age 0 and 0%365 = 0

2 Likes

The question was slightly different (join date rather than birth date this time) but the same logic should’ve been able to be applied in this scenario.

1 Like

Here’s something you could use:

``````local Player         = game:GetService("Players").LocalPlayer;
local Age            = Player.AccountAge;
local isAnniversary  = function(age)
if (age == 0) or (age % 365 == 0) then
print("He joined today!");
end;
end;
isAnniversary(Age);
``````
1 Like