homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Optimal to store user time zones?
JAB Creations

 8:37 am on Sep 8, 2010 (gmt 0)

I currently have all my code processing time zones as GMT however one of the last things I have gotten around to is storing the time zone preference the user chooses. So my question is what it the optimal data type for storing time zones? In example I see in an old copy of phpBB they store time zones in a column set to decimal(5,2), plus I'm not sure what kind of values to expect in there inherently...perhaps if you're on a half-hour split zone something like 4.3 (for +4:30) or -3.3 (for -3:30)? I just want to be sure I'm going about this the correct way.

- John



 11:30 am on Sep 8, 2010 (gmt 0)

I wouldn't store timezones in values, because you can't cope with daylight savings time that way. Better is to store the timezone as VARCHAR() and use the ASCII timezone identifiers. Most scripting languages have functions to convert UTC times to local times when you supply the timezone identifier.

If you are using PHP, a list of accepted timezones can be found here [php.net].

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved