ID:2244993
 
Hey guys, so I'm trying to make a way for me to be able to see how old someone's account is, currently I got the following code:

    if(!timejoined) // No join time set, so we assume he's new.
timejoined = time2text(world.timeofday, "DD,MM,YYYY")


Now that's great and all, but now I need to make a proc that counts how many days are between the timejoined variable and the current date. And I am not sure how to do that..

First, you'd want to store it as world.realtime, and not timeofday, timeofday is per-day, not forever.

Next you'll just want to subtract the timejoined from the current world.realtime, that'll give you how many tenths of a second since you created your character. Run that through some math and there ya go.
In response to Nadrew
Nadrew wrote:
First, you'd want to store it as world.realtime, and not timeofday, timeofday is per-day, not forever.

Next you'll just want to subtract the timejoined from the current world.realtime, that'll give you how many tenths of a second since you created your character. Run that through some math and there ya go.

Yeah I'm awful at math and this especially, care to give me a nudge into the right direction?

I looked it up and found that this may be close to what I'm looking for: datejoined - world.realtime / 864000
1/10th of a second is 0.1
0.1 * 10 = 1 second
60 seconds in a minute * 10 = 600
600 x 60 minutes in an hour = 36,000
36,000 x 24 hours
= 864,000 per day.
In response to GreatPirateEra
So my code is correct and will work then?
In response to Laser50
Since division has a higher priority than subtraction, you would want parentheses around the difference:
days_since_joined = (world.realtime - datejoined) / 864000
// assuming "datejoined" was set to world.realtime when joined
In response to Kaiochao
Kaiochao wrote:
Since division has a higher priority than subtraction, you would want parentheses around the difference:
> days_since_joined = (datejoined - world.realtime) / 864000
> // assuming "datejoined" was set to world.realtime when joined
>


Awesome, fixed some of my own stupidities and it seems to be functional, although is it correct that it is displaying "days old is -0.0148148" at the moment?
In response to Laser50
Oops, the subtraction should be flipped.

world.realtime is never going to be less than datejoined, so... yeah.