* Hassan Shaikh > Thank you for your informative coverage regarding the captioned. > According to your recommendations I've created a separate location > table which contains time zone difference in (+/-) minutes. As per the > server, my assumptions is that it's located somewhere in California, > U.S. (my hosting provider is using EV1). My question is, how to write > bulletproof code so that my server code (in PHP) would always store > date/time in GMT?
Bulletproof... :) The way I understand the above, you don't own the server. The owner of the server could change the clock of the server at any time without your knowledge, there is afaik no way your PHP-code can verify if the current time is 'correct' or not. This means you have to trust the time on the server, or do a lookup from the PHP code to some external time server you do trust. Look at this, for instance: <URL: http://www.kloth.net/software/timesrv1.php > If you can, use UTC instead of GMT on the server. UTC is GMT without DST. That way the server is allways 'zero'. If you can't, you need a global server offset, like I described in a previous message (Re: Time Zone), except you should have the server offset in minutes, or perhaps seconds, depending on your need for accuracy. You must also take into account that the server can use DST, suddenly skipping an hour or repeating an hour... > Also, how do I tackle DST, and automatically adjust incoming time for > daylight saving changes. Appreciate your input and help. This is not so easy, as different countries have different DST, even within the same timezone. You need a country table storing start/end/offset of DST (offset is usually 1 hour, but not allways). Some countries don't use DST. In US different states can have different DST, even within the same timezone. In addition there are local transitions every year: some country may change DST that particular year because of some special happening or other local conditions. You can read more about DST here: <URL: http://www.timeanddate.com/time/aboutdst.html > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]