get and set timezones

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
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

get and set timezones

Post by raghavan20 »

I am looking to get the current time zone and change it to EUROPE, if possible UK GMT.
I tried date_default_timezone_get() but the command does not seem to be recognized.
Anybody know the code like UTC for UK time setting using date_default_timezone_set()???
Stewsburntmonkey
Forum Commoner
Posts: 44
Joined: Wed Aug 24, 2005 2:09 pm

Post by Stewsburntmonkey »

There are actually GMT variants of the core date functions:

gmdate()
gmmktime()
gmstrftime()


You can use the setlocale() function to change the time zone if you need to. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

both of those functions are in 5.1.0

date('Z'); will tell you what time zone you are in (on the server)

gmdate() will generate a GMT based time.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

feyd, date('Z') returns 10800. wots the meaning of that???
Is it possible to tell an application or a file to use a particular zone say for example GMT as standard?
When we use NOW() in Mysql it uses local server time, if I want that in a different timezone how do I do that???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

Z	Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.	-43200 through 43200
I personally always store timestamps in integer form in databases. However, this may help you find what you need to change.. although you could simply perform the necessary calculations in your queries..
Post Reply