Jump to content

Recommended Posts

Posted

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

:)

Posted

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.

Posted

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...

Posted
This should correct your timezone problem as well as automatically take Daylight Savings Time into account when it is in effect.

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?

Posted

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

Posted

Hey, sorry I missed that you were new to the forums... welcome!

Posted

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. :D

 

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. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...