Sign In Register

How can we help you today?

Start a new topic
Answered

Time Zones and daily login

Hi i need an event that runs daily and checks if a user logged in that day. But i need to consider players local time zone while doing that. will "new Date().getDate() " returns the date of server's locale or or player's locale? if it returns server's how can i correct it?


Best Answer
Once again, the everyday script will run at 24.00, midnight, UTC time. You cannot update or change this time, so the best solution i can offer is to check the time between logins or to update the time with the players local time and sync the server calls.
However, i think you are over complicating things by thinking of this in terms of local-time and server time. If you think of this in terms of time between logins, you can always check for 24hr login period no mater what the time or difference between local and server time.

Sean

 


new Date() will always return the server time, which in our case will be UTC. There is no way to avoid this.
However, there may not be a need as there is already an 'Every Day' system script. You could just check the if the player is online there and save the current date to the player's script data. Then, in the every-day update you check the previous date is one day less than the current date, and if it is, mark the player as logged in for the day and update the date.

Does that work?

 

how does every day / ever hour thing works? does it executed with players time? or server time? and when "every day" resets? 00:00 UTC? if so, according to server time or player time?

Good point!

Yes, you are right, this would only get checked at midnight UTC, so there could be some overlap for players in different regions that would put off your analytics.
The solution is just to do the same thing, but in the every hour script.
Does that make sense?

 

makes sense but still as far as i understood that only makes me able to reach server time. I'm not sure how am i gonna distinguish a player (let's say @gmt+3) with an other (@gmt+1).

even through i try to get Date().Today() it will still give me day according to server time right? how am i gonna compansate for it?

So you can pass the time zone info in an event and then the server can adjust the UTC last logged in time based on the time zone, to determine if the the day was today or not.


If you're using C#, here's how you might go about that: https://msdn.microsoft.com/en-us/library/system.timezone.currenttimezone(v=vs.110).aspx


Just know a user could modify the time on their device so they might game the system. In your case it seems that wouldn't be disastrous though.


So if you just want to check that the player has logged in that day, i dont see why you need to worry about the time-zone. If you check the last login time every hour, you can just compare the current server time with the last login time and if they are 24hrs apart, then mark the player as not logged in for the day.
So, because it checks every hour, it doesnt matter what the time-zone is because a user is always offset from their last login. Even if that login is server-time, and not local-time, it is still checks 24hrs minus current server time.

In other words for someone in Istanbul, logging in at 9am, and someone in London logging in at 9am, the same time must pass when the server compares the two times.

With regards comparing two players in different time-zones, it still doesnt matter then, because the server doesnt care about the time-zone, it only cares about the time it recorded them logged in at, and checks 24hrs after that time.

Now, if by 'daily' login you want to tell if a user logged in during their time-zone's day-light hours, that's a different thing.

Sean

 

I think you are misunderstanding what he wants (though I could be wrong).


He's interested in finding out if the player has logged in between 12:00AM-11:59PM according the their local time. And for that, he would need to deal with timezone offsets.


For instance, it's 9pm in Istanbul and the player logs in. Then when they log in at 7am the next day, they should get the reward even though it's not been 24 hours since.

@ryan yes, you are right. i'm intrested in finding players logged in between 12:00AM-11:59PM according to their local time

@sean That is a solution but then players can login 36 hours apart (assuming you are checking their current - last login time is >24 and <48) and they would make them loose opportunities. if i make it >20h and <44h then same problem occurs if they login every 21hour. this is why i need to check restrictively "first login of the day".

Can i get an insight about everyday script? how does it works? It looks like i can't get any help off setting time zones. so if i know how "every..." scripts works i can try to find a solution to my problem.

Answer
Once again, the everyday script will run at 24.00, midnight, UTC time. You cannot update or change this time, so the best solution i can offer is to check the time between logins or to update the time with the players local time and sync the server calls.
However, i think you are over complicating things by thinking of this in terms of local-time and server time. If you think of this in terms of time between logins, you can always check for 24hr login period no mater what the time or difference between local and server time.

Sean

 

Login to post a comment