Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i split an account age into years, months, and days?

Asked by 4 years ago

I'm eyeing something to do with os.date here. but if i get the year from the table it says 1969.

if v is a player whose AccountAge is 2:

>> os.date("*t", v.AccountAge * 86400).year
1969

1 answer

Log in to vote
1
Answered by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

AccountAge just gives you how many days its been since the player joined Roblox, It does not act like a UNIX timestamp would. Its returning 1969 because that is the UNIX epoch, 1 in a UNIX timestamp. To get the result you want you will need to do some math.

AC stands for AccountAge.

AC/365

Will give you how many years its been since the account was created

((AC/365) - math.floor(AC/365)) * 12

Will give you how many months its been since the account was created, minus the years.

((AC/30) - math.floor(AC/30)) * 30

for the days

To get the UNIX date just subtract each result from the current date.

Now combine these in code

local var = AC/365 .. ((AC/365) - math.floor(AC/365)) * 12 .. ((AC/30) - math.floor(AC/30)) * 30
0
hmm. It's a bit unfortunate that i can't account for non 30 day months, but i'll accept it. thanks. mightydifferent 85 — 4y
0
you can get closer though, instead of 30 use 30.417 Benbebop 1049 — 4y
0
Hey, i didn't think of that, thanks! mightydifferent 85 — 4y
Ad

Answer this question