![]() |
Users Timezone
Hey, hope all are well. I have a question.
My project is pretty big, and can only hope for global success. Currently all the times on the website are using the server's clock, which is 6 hours behind my clock (It's in the USA and I'm in the UK). I will allow my users to set there timezone via a select menu, the same as a lot of forums (including this one) use in it's control panel. I'll be storing the value in the 'member' table. What I'm not 100% sure on is how to use the value to display the time in their timezone. My timezone would be '0 - GMT' but with the server time been six hours behind my clock, would I add '+6' instead? When I output a time, I want it to be the time in their timezone, so, my first though was to do something like this: Code:
echo date('D M, Y' time()+$row->timezone);P.S. Hope I made sense :P |
I'd go one of two, maybe three ways at a push, in achieving this.
Method 1: Using strtotime()Downsides: Not the fastest function in the world but gets the job done. PHP Code:
mktime()Downsides: Long line. Uses functions inside functions which can look exceptionally messy. PHP Code:
date_default_timezone_set or putenvDownsides: Very little! Just wish this function was more heard of. PHP Code:
PHP Code:
|
While date_default_timezone_set looks tempting, I can't see how it would work with the values of the select menu, which will be '0, +1, +2... -2, -1' etc. Unless those values would work with the $timezone_identifier, but I see no mention of that in the manual. I think I may just go with strtotime()
Unless anyone has any follow up's to my query, thanks for the help Wild Honey. |
| All times are GMT. The time now is 03:55 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0