我正在修改一个现有的应用程序,该应用程序经常使用常量SERVER_TIMEZONE_OFFSET
。我以前从未遇到过这种情况,而且在搜索“SERVER_TIMEZONE_OFFSET”时,最接近的结果是PHP文档中的timezone_offset_get()
函数。
以下是一个查询示例,其中使用了`SERVER_TIMEZONE_OFFSET。
$sql = "select s.weekNum, count(s.gameID) as gamesTotal,";
$sql .= " min(gameDateTime) as firstGameTime,";
$sql .= " (select gameDateTime from schedule where weekNum = s.weekNum and DATE_FORMAT(gameDateTime, '%W') = 'Thursday' order by gameDateTime limit 1) as cutoffTime,";
$sql .= " (DATE_ADD(NOW(), INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) > (select gameDateTime from schedule where weekNum = s.weekNum and DATE_FORMAT(gameDateTime, '%W') = 'Sunday' order by gameDateTime limit 1)) as expired ";
$sql .= "from schedule s ";
$sql .= "group by s.weekNum ";
$sql .= "order by s.weekNum;";
这是我尝试修改它的方式
//只是添加了$SQL行,我已经从上面的代码中进行了更改
$sql .= " (DATE_ADD(NOW(), INTERVAL " . date_default_timezone_set('Australia/Brisbane') . ") > (select gameDateTime from schedule where weekNum = s.weekNum and DATE_FORMAT(gameTimeEastern, '%W') = 'Sunday' order by gameTimeEastern limit 1)) as expired ";
上述查询会导致一个错误信息,简单地指出在你的SQL语句中有一个错误,附近是date_default_timezone_set('Australia/Brisbane') . ") >
问题
- 在上下文中,
SERVER_TIMEZONE_OFFSET
的确切目的是什么? - 我如何编辑查询
SERVER_TIMEZONE_OFFSET
以接受date_default_timezone_set('Australia / Brisbane')
,我的尝试不成功,您有任何指针告诉我哪里错了吗? - 是否有可能使用MySQL语句替代
SERVER_TIMEZONE_OFFSET
,我可以使用?