edsel99 Posted May 26, 2005 Posted May 26, 2005 I keep my Volleyball schedule on my website. I use PHP Scripts to retrieve the game time from the MySQL database. Everything was working great until just recently and I noticed all of the times were an hour off. For example the real game time that is entered into the database is 6:45 PM. When I look at my website it is displaying 7:45 PM. This has been working since November and just recently stopped. My only guess is that it has something to do with Daylight savings. I am using the UNIX_TIMESTAMP() in my SQL statement and date("M j",$gamedate) in my PHP script. Any help on how to fix this problem would be appreciated. Other wise I will be forced to adjust in the script for DST. If this is my only options what dates are the breaking points for DST. Eric Grinnell http://www.peakfinder.net Quote
Deverill Posted May 26, 2005 Posted May 26, 2005 Depending on your scripts, it could be simply that the Data Center that holds your web site is in another time zone, 1 hour off from you. Quote
TCH-Thomas Posted May 26, 2005 Posted May 26, 2005 Welcome to the forum, edsel99. Not sure if this will help but here are a great site for all kinds of DST info. Quote
TweezerMan Posted May 26, 2005 Posted May 26, 2005 Welcome to the forums, Eric! Assuming TCH-Jim is correct that you are 1 timezone off from your web server, you could set an environment variable in your PHP script that would force PHP to calculate dates and times for your timezone instead of the server's. At the beginning of your script, add the following line: >putenv("TZ=PST8PDT"); Use the value for TZ below that corresponds to the timezone you're in (assuming U.S. timezones here): Pacific - PST8PDT Mountain - MST7MDT Central - CST6CDT Eastern - EST5EDT This should correct your timezone problem as well as automatically take Daylight Savings Time into account when it is in effect. After you've made this change to your script, I'd suggest checking the date/times that are already on your web page and make sure they're showing the correct date/time (that they're now not an hour off). If they are, you'll need to correct to date/time in the database. Hope this helps... Quote
abinidi Posted May 26, 2005 Posted May 26, 2005 This should correct your timezone problem as well as automatically take Daylight Savings Time into account when it is in effect. <{POST_SNAPBACK}> Would this be an easy fix to the PHPBB lack-of-DST support? Oh wait, no it wouldn't, because PHPBB lets users select their own time zone. Does anybody know how to make PHPBB work with DST better? Quote
edsel99 Posted May 26, 2005 Author Posted May 26, 2005 I guess I don't understand why it's adjusting the time anyway. I have a date time value in the database (i.e. 5/25/2005 6:45 PM). I request that field from the database and ask the php script to print it on the page. I don't understand why it is taking that date and adding an hour. If I add in the Eastern - EST5EDT when looking at gametimes from last winter will those now be an hour off? I guess I will add it and see. Thanks Eric Quote
Deverill Posted May 26, 2005 Posted May 26, 2005 Hey, sorry I missed that you were new to the forums... welcome! Quote
TweezerMan Posted May 26, 2005 Posted May 26, 2005 I don't know if the times from last winter will be an hour off or not - that's why you should test my suggestion and see if it works, or makes things worse. For Eastern time zone, you should add: >putenv("TZ=EST5EDT"); ...to your script and see what it does. If it doesn't solve your problem, then just remove the line so your script is back as it was. Quote
stevevan Posted May 27, 2005 Posted May 27, 2005 Welcome to the forums. Did the script suggestion work? Quote
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.