PHP Timezone from MySQL Database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

PHP Timezone from MySQL Database

Post 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.
tomsace
Forum Contributor
Posts: 167
Joined: Thu Jan 01, 2009 8:07 pm

Re: PHP Timezone from MySQL Database

Post 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!
Post Reply