if (isset($_SESSION['user_tz'])) {
$posted = "CONVERT_TZ(p.posted_on, 'UTC', '{$_SESSION['user_tz']}')";
} else {
$posted = 'p.posted_on';
}
// Run the query:
$q = "SELECT t.subject, p.message, username, DATE_FORMAT($posted, '%e-%b-%y %l:%i %p') AS posted FROM threads AS t LEFT JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON p.user_id = u.user_id WHERE t.thread_id = $tid ORDER BY p.posted_on ASC";
I changed the $posted in the query to a plain “posted_on” which returned the time, I also tried some wrapping it in ” and “” but those ended up breaking it entirely; for future reference I’d like to know why that variable isn’t getting passed through to the query. It’s probably something really simple and I’ll feel silly but help would be appreciated greatly.
Thanks.
NULL is a valid value for isset() to trigger TRUE. Use
unset($_SESSION['user_tz']);