Daylight Savings?

liunx

Guest
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.<br /><br />I am using the UNIX_TIMESTAMP() in my SQL statement and date("M j",$gamedate) in my PHP script.<br /><br />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.<br /><br />Eric Grinnell<br /><a href="http://www.peakfinder.net" target="_blank">http://www.peakfinder.net</a><br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wallbash.gif" style="vertical-align:middle" emoid=":wallbash:" border="0" alt="wallbash.gif" /><!--content-->
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.<!--content-->
Welcome to the forum, edsel99. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />Not sure if this will help but <a href="http://www.timeanddate.com/" target="_blank">here</a> are a great site for all kinds of DST info.<!--content-->
Welcome to the forums, Eric! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/thumbup1.gif" style="vertical-align:middle" emoid=":thumbup1:" border="0" alt="thumbup1.gif" /> <br /><br />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.<br /><br />At the beginning of your script, add the following line:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->putenv("TZ=PST8PDT");<!--c2--></div><!--ec2--><br />Use the value for TZ below that corresponds to the timezone you're in (assuming U.S. timezones here):<br /><br />Pacific - PST8PDT<br />Mountain - MST7MDT<br />Central - CST6CDT<br />Eastern - EST5EDT<br /><br />This should correct your timezone problem as well as automatically take Daylight Savings Time into account when it is in effect.<br /><br />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.<br /><br />Hope this helps...<!--content-->
Welcome to the forums Eric!<!--content-->
<!--QuoteBegin-TCH-David+May 26 2005, 11:37 AM--><div class='quotetop'>QUOTE(TCH-David @ May 26 2005, 11:37 AM)</div><div class='quotemain'><!--QuoteEBegin-->This should correct your timezone problem as well as automatically take Daylight Savings Time into account when it is in effect.<br /><div align="right"><a href="http://www.totalchoicehosting.com/forums/index.php?act=findpost&pid=132164"><img src='http://www.totalchoicehosting.com/forums/style_images/1/post_snapback.gif' alt='*' border='0' /></a></div><!--QuoteEnd--></div><!--QuoteEEnd--> Would this be an easy fix to the PHPBB lack-of-DST support?<br /><br />Oh wait, no it wouldn't, because PHPBB lets users select their own time zone.<br /><br />Does anybody know how to make PHPBB work with DST better?<!--content-->
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 <br /><br />Eastern - EST5EDT<br /><br />when looking at gametimes from last winter will those now be an hour off?<br /><br />I guess I will add it and see. <br /><br />Thanks<br /><br />Eric<!--content-->
Welcome to the forums Eric and the family <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /><!--content-->
Welcome to the forums, edsel99 <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/kicking.gif" style="vertical-align:middle" emoid=":dance:" border="0" alt="kicking.gif" /><!--content-->
Hey, sorry I missed that you were new to the forums... welcome!<!--content-->
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. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" /> <br /><br />For Eastern time zone, you should add:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->putenv("TZ=EST5EDT");<!--c2--></div><!--ec2--><br />...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. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
Welcome to the forums. Did the script suggestion work?<!--content-->
 
Back
Top