My public charity helps senior generational social dependents (hereditary poor due to a number of factors) learn middle class work ethics and job skills through a Federal program know as the “Senior Aides” or SCSEP program. This program pays seniors minimum wage to learn job skills in a working context. We must sign off on their time sheet every other week to attest that they really, truly, did actually work the hours shown on the time sheet, however these seniors sometimes forget days that they called in sick or left early, so I wrote a simple script as part of our web site that provides a time clock. One button for IN and one button for OUT and the MySQL database records the timestamp perfectly.
The problem I ran into is that we buy hosting on GoDaddy.com which is on the Pacific coast on Pacific time, my agency is located in Fort Wayne, Indiana in the midwest on EDT, and the normal MySQL commands to set the time zone do not work.
mysql_query("SET time_zone = 'America/Fort_Wayne';"); // Does Not Work
mysql_query("SET time_zone = 'America/Indianapolis';"); // Does Not Work
Apparently GoDaddy has not loaded the standard TZ file and they refuse to disclose what I should tell the MySQL server my timezone is. Several of their customer service people told me that if I knew how to tell MySQL which time zone I am in it would leave them open to cyber attack. I have no idea how knowing your timezone string would leave GoDaddy.com open to attack. Moving right along…
This left me changing the timezone manually every spring and fall, which is tedious and occasionally results in very confused Seniors telling me that the time clock is broken because it shows they clocked out an hour early (they never complain that it shows they clocked in an hour early).
// mysql_query("SET time_zone = '-5:00';"); // Uncomment in Fall mysql_query("SET time_zone = '-4:00';"); // Uncomment in Spring
I found a way around this today in the comments on a post at http://www.electrictoolbox.com/mysql-set-timezone-per-connection/
date_default_timezone_set('America/Fort_Wayne'); // set timezone in php mysql_query("SET `time_zone` = '".date('P')."'"); // set timezone in MySQL
Some of the comments say this does not work on BlueHost, but it does work for me on GoDaddy.com.
Hope this helps!
–Kubulai