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 :)
With a small "cheating" (using client side scripting) and posting the result to your server, you can access your client's timezone.
For example you can use this javascript library:
https://bitbucket.org/pellepim/jstimezonedetect
Demo: http://pellepim.bitbucket.org/jstz/
For geolocation you can use http://ipinfodb.com/, work great with an API!
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)The most reliable method is to ask the user to set his own timezone. I think it's a good idea to have a timestamp of when the users account was created in your own database for your own use.
These are the steps I would take to have a users timezone:
1- Preserve the timestamp column that you have for your own usage
2- Add a new column for the actual users timezone
3- Use javascript to retrieve the timezone:
new Date().getTimezoneOffset()/60;<br/>
4- Also allow users to set there own timezone as well
You can also take it a step further and use a geo-location service to detect a users timezone.
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.