PHP Timezone from MySQL Database
Posted: Tue Apr 05, 2011 2:00 pm
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):
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:
And I can't get my head around using:
Any help will be much appreciated.
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")));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');Code: Select all
date_default_timezone_set