Page 1 of 1

PHP Timezone from MySQL Database

Posted: Tue Apr 05, 2011 2:00 pm
by tomsace
Hey,
I have my database setup so that when a user posts a comment, it adds a timestamp when they post it.
I can retrieve the time from the database using the following code (in a loop):

Code: Select all

$time = date("g:i a", strtotime(mysql_result($result,$i,"date")));
Now the problem I am having is changing this time to a different timezone.

I have used the following, but cant get it to work with a time from the database rather than just the current time:

Code: Select all

putenv ('TZ=Europe/London');
And I can't get my head around using:

Code: Select all

date_default_timezone_set
Any help will be much appreciated.

Re: PHP Timezone from MySQL Database

Posted: Wed Apr 06, 2011 5:31 pm
by tomsace
These forums are <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>! does anyone actually visit them anymore?? remove my account mr.administrator because I dont want to be apart of such a waste of time site!