ERuiz Posted January 15, 2007 Share Posted January 15, 2007 Say a member of my website lives in a timezone of -5 GMT, how would I be able to write a code so that when a person looks at this members information, it will show the current time for that member that lives in -5 GMT?Thanks,ERuiz Quote Link to comment Share on other sites More sharing options...
btherl Posted January 15, 2007 Share Posted January 15, 2007 The easiest way is to ask the user at registration time.Of course many users will not know what time zone they are in, but they will know what country and area they are in, so it can be better to ask for that than for the time zone.If you want to automatically detect their time zone, look at "geolocation". That's the word for finding a user's physical location based on their ip address. Quote Link to comment Share on other sites More sharing options...
ERuiz Posted January 15, 2007 Author Share Posted January 15, 2007 Hi btherl,Actually, the timezone is already stored for each member on the database. So I just need to use the value stored and make the calculations from there.Example: $timezone = "-5";How would I write a php code to take $timezone and calculate local time using server's actual time? Quote Link to comment Share on other sites More sharing options...
btherl Posted January 15, 2007 Share Posted January 15, 2007 This function should help.. you can use it along with date() to format the timestamp nicely.http://sg.php.net/manual/en/function.mktime.phpAdd the timezone to the hours argument to adjust the time. Quote Link to comment Share on other sites More sharing options...
ERuiz Posted January 15, 2007 Author Share Posted January 15, 2007 Thanks!!! ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.