hi i am creating a web application , where if a user register we will show the created date.
For that we are using Current time stamp in my sql table.Which shows server Time.But we don't know how to convert Time according to user time zone.
Because we are not getting user's country .
Can any on help me to fix it
Thanks in advance :)
Enabling this feature is easy. Head to Settings > Time & Language > Date & Time and turn on the toggle under Set time zone automatically.
The client's timezone offset could be detected by using the Date object's getTimezoneOffset() method. The getTimezoneOffset() method returns the time difference between UTC time and local time, that is the time offset, in minutes. This offset is changed by dividing by 60 and negating the result.
Pretty much anything you could do in JavaScript on the browser (with exception, of course), you can do in React Native. I would initiate a new date object and call getTimezoneOffset() on it to get the number of minutes the timezone is offset locally.
Use javascript solution
http://www.onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/
Demo should show your timezone in select box.
http://onlineaspect.com/examples/timezone/index.html (Dead link)
You can't get a user's timezone on the server side, and you can only make a guess at it on the client side.
If you rely on getting the user's IP address then you could geolocate that and deduce a time.
The way this is usually done is by asking the user (when they register, for instance) what timezone they are in and then use this in your time calculations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With