zetahoff Posted September 14, 2007 Share Posted September 14, 2007 I have searched everywhere I know to look (yes...I searched google), however, I have thus far been unable to find a solution to my problem. I would like users to be able to log into my site and set the timezone to whatever they want it to be. Well, that was easy. Now I would like the site to display the correct time. That is not so easy, as it turns out. I don't know how to go about accounting for DST in every timezone in the world. I have found functions in PHP to translate the time into a specific timezone, however, the functions would like for me to tell them whether DST is in effect. I HAVE GOT TO BE OVERLOOKING SOMETHING!! Really, it can't be this hard. The only solution I have come up with is to write a script to manually account for each timezone's DST rules (which apparently changes from region to region within each timezone). If anyone can help me break this wall of stupidity (it has to be something I am overlooking, right?), please do so. You can even let me know how stupid I am. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/ Share on other sites More sharing options...
zetahoff Posted September 15, 2007 Author Share Posted September 15, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348764 Share on other sites More sharing options...
AndyB Posted September 15, 2007 Share Posted September 15, 2007 Personally, I'd choose to break the wall of stupidity and ignore arcane tribal customs like DST. GMT will be the same all around the planet no matter what strange variants apply to 'local' time. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348769 Share on other sites More sharing options...
zetahoff Posted September 15, 2007 Author Share Posted September 15, 2007 Right, however, most of my users are local and would like to have their local time and date displayed on the server. The entire purpose of my webpage (as are most webpages) is to make the life of the user easier. So it would just make sense to display the timezone that they would like to set themselves in accurately. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348795 Share on other sites More sharing options...
Jessica Posted September 15, 2007 Share Posted September 15, 2007 Did you look in the manual? http://www.php.net/manual/en/function.timezone-offset-get.php There are 6 or 7 functions at the bottom having to do with timezones, that address the local DSTs of those. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348796 Share on other sites More sharing options...
Psycho Posted September 15, 2007 Share Posted September 15, 2007 timezone_offset_get only works if you know what timezone region the user is in. Just knowing the user's timezone is not enough to tell you if they observer DST or not. There are states in the US where some counties observer DST and others do not. Right, however, most of my users are local and would like to have their local time and date displayed ... If they are local then just adjust the time based upon your local settings. There just is no perfect way to do this. You can either go the simple route of assuming everyone does observe DST and set the fall ahead and back to one region's dates, or you can get real complex and "try" and determine what region they are in based upon IP and the tme zone they choose and then build a huge database of locals and what their start and end of DST is. Or, you could try a Javascript hack. Basically, when they choose their time zone also have two hidden fields on the page. Use some javascript to determine their DST start and end, then populate the hidden fields with those fields. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348797 Share on other sites More sharing options...
zetahoff Posted September 15, 2007 Author Share Posted September 15, 2007 Thanks for the help, jesirose. Yes, I had already looked in the PHP manual, however, the DST is still not acurate according to the function you linked to. No, it's not the only function I looked at. And thank you as well, mjdamato. I had thought of that, as well. However, if my user is viewing their data while traveling, they still want the data to appear in the timezone they had chosen before they left for the trip. So I wouldn't be able to rely on the timezone they are currently in. A better example would be if a CEO wanted to view sales by hour in a store in Texas, but he was in Japan, how could I go about displaying the data for him in the Texas timezone? It wouldn't be too difficult if I knew beforehand which timezone's my user's would select. I guess what it comes down to is I will have to give the user the option to choose their timezone from a very long list, such as provided here: http://uk.php.net/manual/en/timezones.php and then use the old TZ to set the timezone. I simply thought there HAD to be an easier way of doing this, especially since several forums, including this one, go ahead and take account for the timezones of their users. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348806 Share on other sites More sharing options...
Jessica Posted September 15, 2007 Share Posted September 15, 2007 When they are traveling, they're probably not changing their computer's time. Why not just let them select DST yes or no when they select their timezone? Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348809 Share on other sites More sharing options...
zetahoff Posted September 15, 2007 Author Share Posted September 15, 2007 Ok, so that solution helps if I tell all my clients that they must bring laptops with them whenever they travel, don't use the computers at the head office to check their data unless they want to do the time calculations, and they need to let me know when the time changes, and how many hours it changes, and in which direction. Seems like there should be an easier way to do this.... Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348814 Share on other sites More sharing options...
Psycho Posted September 15, 2007 Share Posted September 15, 2007 if my user is viewing their data while traveling, they still want the data to appear in the timezone they had chosen before they left for the trip. Um, didn't I suggest that you use JS to identify their DST settings when they initially set their timezone? How would that change the time that is displayed to them when they are travelling. If they choose to reset their time zone to the local time then there is nothing you can do. Why are you thinking they have to bring laptops with them? The timezone they selected when registering on the site is the timezone you will use to display time to them It will have nothing to do with what timezone they are actually located in. Quote Link to comment https://forums.phpfreaks.com/topic/69359-daylight-saving-timesimple/#findComment-348869 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.