Well I'm continuing my integration of xenforo with my own application and the next thing I was looking into was timezones and using the user offsets to show times specific to a user's setup.
One thing that really confused me is that Xenforo (for a few hours I thought it was my PHP Library - Cakephp) was changing the timezone to UTC (whereas I had it set to Europe/London.
An apparent side effect of that is below (the latter line being the correct time):
With Xenforo
Time: 1309039177 Date: Sat 25 Jun 2011, 9:59 PM UTC
Without Xenforo
Time: 1309039177 Date: Sat 25 Jun 2011, 10:59 PM BST
If I changed my code to use Xenforo's own timezone/locale function like so:
It instead produced this:
Time: 1309039177 Date: Sat 25 Jun 2011, 10:59 PM UTC
Which produces the correct time but the wrong timezone information. That time is BST or UTC+1 not UTC. If I displayed that to the end user then it would be giving the wrong information.
If I'm approaching this wrong then I'd appreciate it if someone could point me in the right direction.
One thing that really confused me is that Xenforo (for a few hours I thought it was my PHP Library - Cakephp) was changing the timezone to UTC (whereas I had it set to Europe/London.
An apparent side effect of that is below (the latter line being the correct time):
PHP:
echo "Time: ".time()." Date: ".date("D d M Y, g:i A T", time())."<br />";
With Xenforo
Time: 1309039177 Date: Sat 25 Jun 2011, 9:59 PM UTC
Without Xenforo
Time: 1309039177 Date: Sat 25 Jun 2011, 10:59 PM BST
If I changed my code to use Xenforo's own timezone/locale function like so:
PHP:
echo "Time: ".time()." Date: ".date("D d M Y, g:i A T", time()+(Xenforo_Locale::getTimeZoneOffset()))."<br />";
It instead produced this:
Time: 1309039177 Date: Sat 25 Jun 2011, 10:59 PM UTC
Which produces the correct time but the wrong timezone information. That time is BST or UTC+1 not UTC. If I displayed that to the end user then it would be giving the wrong information.
If I'm approaching this wrong then I'd appreciate it if someone could point me in the right direction.