Reputation: 229
I am developing an app in android in there will be users posting posts from different countries.I want to know how user will get to know the time at which they upload a post to the app. I want to get their local time using my app.
Upvotes: 0
Views: 931
Reputation: 8945
Ordinarily, this chore is simply done for you, according to the user's own preferences as set on the phone. (Commonly called a "locale.")
The resulting date/time value is a number that, IIRC, basically is "UTC." It's an absolute value.
If someone else displays that value on their phone, they will see it expressed in whatever time-zone they've specified for their phone. The "moment in time" will be the same moment.
Upvotes: 0
Reputation: 945
I think the only solution is to follow these steps:
Please do check out the documentation at the following link: https://developer.android.com/guide/topics/location/strategies
Upvotes: 0
Reputation: 654
Please refer to this answer for multiple different ways of getting a users current date and time. These times can then be freely converted between timezones, allowing you to store them in some specfic time such as UTC and display them in a users local time.
Upvotes: 0
Reputation: 336
Well, if you have any centralized database system to save all data related to posts, you can specifically save time in UTC. When displaying you can convert it according to each and every timezone.
Upvotes: 1