Updated PHP SERVER_TIMEZONE_OFFSET

I am working on modifying an existing application that uses a constant SERVER_TIMEZONE_OFFSET, using A LOT. I have never come across this before, and the closest search I can get for "SERVER_TIMEZONE_OFFSET" is in PHP Docs for the functiontimezone_offset_get()

The following is an example query that uses 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;";

Here is my attempt to change it

//only adding $SQL row I changed which I changed from above code

$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 ";

In the above query, an error message appears stating that you have an error in your sql syntax next to date_default_timezone_set('Australia/Brisbane') . ") >

Question (s)

  • What is the purpose SERVER_TIMEZONE_OFFSETin the context above?
  • How can I edit the request SERVER_TIMEZONE_OFFSETto accept date_default_timezone_set('Australia/Brisbane'), obviously, my attempt was unsuccessful, any pointers that I made a mistake in?
  • SERVER_TIMEZONE_OFFSET mysql, ?
+4
1
INTERVAL " . SERVER_TIMEZONE_OFFSET . " HOUR) 

, , .

INTERVAL 5 HOUR
         ^ 

, . , PHP , MySQL . MySQL , ,

SERVER_TIMEZONE_OFFSET - , , , . , , .

, . PHP , .

define("SERVER_TIMEZONE_OFFSET",6);  // Or any number you see fit
+1

Source: https://habr.com/ru/post/1666979/


All Articles