Page 1 of 1

Changing Timezone

Posted: Tue Apr 21, 2009 12:56 pm
by EPX
Hi all,

i hope this is a really simple answer to my question as i have been trying to find one for the past few hours.

i'm trying to convert a timestamp from UTC into the users relevent timezone.

Currently i save all timestamp to the database as UTC and when i pull them out i need them changing. the user has a timezone assigned to their record e.g 'Europe/London'

i need in PHP to say UTC is the current timezone for this timestamp, now change it to timezone 'Europe/London' or any other.

Has anyone got any ideas?

p.s i have looked into the CONVERT_TZ in mysql but the timezone table isn't setup on the server and i can't access it.

Re: Changing Timezone

Posted: Tue Apr 21, 2009 1:08 pm
by requinix
Raw timestamps don't have a timezone. They're UTC or just plain numbers.

So what are you storing? DATE? UNIX_TIMESTAMP? time()?

I store numbers - what MySQL's UNIX_TIMESTAMP and PHP's time give. Then with PHP 5 I use date_default_timezone_set to set a timezone and date to convert the number into a string - the timezone is handled automatically.

So more details, if you please.