I want to get the time zone for each player. Is there any suggested way to do this?
I want to have a time offset field for each player, so I can send global push notifications at appropriate times.
Best Answer
C
Customer Support
said
over 4 years ago
Hey Baris,
The server has no way to determine the time for the player itself, other than the geolocation (which is unfortunately not always accurate). The conventional way of doing this is to submit the client's local-time to the server on authentication and calculate the time-difference (timeDelta) and store that on the player-doc. If you then need to preform and time-based calculations or comparisons, you add/subtract the timeDelta for each player.
If using Unity you could pass the timezone info in an event. The TimeZoneInfo class should be useful.
Thanks,
Oisin
Customer Support
said
over 4 years ago
Answer
Hey Baris,
The server has no way to determine the time for the player itself, other than the geolocation (which is unfortunately not always accurate). The conventional way of doing this is to submit the client's local-time to the server on authentication and calculate the time-difference (timeDelta) and store that on the player-doc. If you then need to preform and time-based calculations or comparisons, you add/subtract the timeDelta for each player.
Does that make sense? Sean
B
Baris Tumerkan
said
over 4 years ago
Yes, this is a good idea, thanks. We'll use this in addition to TimeZoneInfo.
For the previous users for whom we didn't have this info though, I intend to use a BulkJob to convert country data to time offsets. Do you have any suggestions for doing this?
( If anyone intends to use TimeZoneInfo for this, but for some users it can't find a TimeZoneInfo and causes an exception, so make sure to wrap it in a try-catch block. )
Customer Support
said
over 4 years ago
Hi Baris, currently looking into a solution for you.
Baris Tumerkan
I want to get the time zone for each player. Is there any suggested way to do this?
I want to have a time offset field for each player, so I can send global push notifications at appropriate times.
The server has no way to determine the time for the player itself, other than the geolocation (which is unfortunately not always accurate).
The conventional way of doing this is to submit the client's local-time to the server on authentication and calculate the time-difference (timeDelta) and store that on the player-doc.
If you then need to preform and time-based calculations or comparisons, you add/subtract the timeDelta for each player.
Does that make sense?
Sean
1 person has this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Baris,
If using Unity you could pass the timezone info in an event. The TimeZoneInfo class should be useful.
Thanks,
Oisin
Customer Support
The server has no way to determine the time for the player itself, other than the geolocation (which is unfortunately not always accurate).
The conventional way of doing this is to submit the client's local-time to the server on authentication and calculate the time-difference (timeDelta) and store that on the player-doc.
If you then need to preform and time-based calculations or comparisons, you add/subtract the timeDelta for each player.
Does that make sense?
Sean
Baris Tumerkan
Yes, this is a good idea, thanks. We'll use this in addition to TimeZoneInfo.
For the previous users for whom we didn't have this info though, I intend to use a BulkJob to convert country data to time offsets. Do you have any suggestions for doing this?
( If anyone intends to use TimeZoneInfo for this, but for some users it can't find a TimeZoneInfo and causes an exception, so make sure to wrap it in a try-catch block. )
Customer Support
Hi Baris, currently looking into a solution for you.
Best Regards, Patrick.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2486 topics