I have a weird problem concerning mysql timezone.
In my website config file i have this line which sets the timezone :
mysql_query("SET SESSION time_zone = '$offset';"); // Offset is properly calculated, no worries about that
The funny part is that if i add another line right after this like this :
$q = mysql_query("SELECT NOW() as now");
$row = mysql_fetch_array($row);
echo $row["now"];
After executing that code, the time is displayed correctly.
BUT, in some other queries i insert rows in tables that have a column named date that defaults to CURRENT_TIMESTAMP.
Rows are inserted like this:
INSERT INTO `sessions` (`user_id`) VALUES `1`
(The sessions table has a date
column that defaults to CURRENT_TIMESTAMP)
But the value inserted in DB still points back to the timezone of the server :((
Any ideas how to work through this ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…