GlowHost Web Hosting Forums  

Go Back   GlowHost Web Hosting Forums > In The Lounge > Programming Talk
Register Forum FAQ Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 03-14-2008
Scott's Avatar
Practically a Glow Sage
 
Join Date: Oct 2006
Posts: 24
Rep Power: 0
Scott is on a distinguished road
Default

After discussing this further off-line, I have come to the conclusion that I believe it would always be best to handle any recording of time into MySQL as GMT. Then to simply let PHP handle the displaying of time into your intended time zone.

This would allow you to change the time zone domain wide by using the Apache directive. Then as Matt has pointed out and you have visitors that require the time to be displayed differently, you can override the default time zone set by Apache with PHP.

As Mysql is concerned you can then make the adjustment on a per connection basis by setting the time zone to "0".

I believe this would also aide in making your code more portable.

This is my conclusion, any other thoughts or holes in my train of thought here?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 03-14-2008
Matt's Avatar
chown -R us.us *YourBase*
 
Join Date: Jan 2005
Location: Moved to Florida!
Posts: 1,725
Rep Power: 10
Matt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of light
Default

I think I too have heard that the way to do it is in fact, GMT. It does ring a bell anyways.

The only portability problem I see is that not everyone uses Apache webserver.

I suppose it would not much matter for you unless you plan on making this application for sale or distribution, and then, I still wonder. I think the more you can keep out of .htaccess the better though, because different web servers either do not read that file, or may interpret it differently than Apache does.

Why not let PHP do all the time processing based on GMT in MySQL?
__________________
:::::
01001100 00110011 00110011 00110111

Last edited by Matt; 03-14-2008 at 11:29 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 03-24-2008
Dmitriy's Avatar
Moderator
 
Join Date: Feb 2007
Location: Ukraine
Posts: 25
Rep Power: 0
Dmitriy is on a distinguished road
Default

Well, yes, PHP uses server local time. You can obtain if local server time is in DST (call date('I')). As for MySQL - it depends on configuration. Check MySQL manual: A.4.6. Time Zone Problems.

However, from the PHP script you can't determine if (let's say the server is in Florida) if in New Ziland is used DST right now. See: About Daylight Saving Time. That is why many PHP applications have 'Use DST' in options (it simply adds 1 hour to the user timezone).

JM, Scott, any comments?

Very interesting situation arises, when user says his timezone is GMT +2 & he is in country that uses DST..... so what the current user time is? Anybody knows for sure?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 03-24-2008
Dmitriy's Avatar
Moderator
 
Join Date: Feb 2007
Location: Ukraine
Posts: 25
Rep Power: 0
Dmitriy is on a distinguished road
Default

Finally, after few hours of searching, found & tested a script. Seems working good:
Timezone and Daylight Saving Time Script
However, I wasn't able to check many timezones... Have a look at it
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 03-24-2008
Matt's Avatar
chown -R us.us *YourBase*
 
Join Date: Jan 2005
Location: Moved to Florida!
Posts: 1,725
Rep Power: 10
Matt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of lightMatt is a glorious beacon of light
Default

From his site:

Quote:
At the time of writing this, I am aware that the United States is considering passing legislation that would change their daylight savings time rules with Canada to possibly follow suit. Once these new rules are made official, I will make an effort to update this script to reflect the changes.
I believe this was passed this year. Though I forget what it was, I think what it entailed was a change to the date that DST was recognized on.

Can anyone confirm or deny that the changes have already been made?
__________________
:::::
01001100 00110011 00110011 00110111
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 09:11 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO
Copyright 2000-2007 GlowHost.com