Hi guys. I hope you can help me with these please... I'm completely stumped
We use a timezone selection for locale, and I want to further use that to basically (when someone is logged in) to show all the website dates in their own time. This includes dates stored in our MySQL database.
The timezone selections are at http://pastebin.com/mf714dfa (too large to post here), these are the values that are in our timezone
field in our user
table
So, that's fine...
In my functions.php, included by all files I've tried the following:
if (isset($_SESSION['logged'])) {
$search=mysql_fetch_array(mysql_query("SELECT * FROM user WHERE account='".mysql_real_escape_string($_SESSION['account'])."'"));
$timezone=$search['timezone'];
date_default_timezone_set($timezone);
}
It changes normal date()'s, but NOT when it's combined with strtotime. So basically, none of our database dates are being changed, which we use like:
date('M d H:i:s Y', strtotime($row['dateposted']))
And also (to rule out it was the database) the following strtotime (nothing to do with our database) has the same behaviour:
date("l dS M Y H:i", strtotime('2004-08-12 10:18'));
The above two date()'s combined with strtotime() just show it as it's inserted in the database; not modified to the user's timezone
We also had another problem (which was an expected one) that the dates we inserted into our database were being inserted at the user's timezone. We expected that, so instead we're now using gmdate() for the date of insertion, which is perfect.
Any help you can provide will be gratefully appreciated