Page 1 of 2
Timezone Setting
Posted: Mon Aug 29, 2005 2:10 pm
by nuspace
Is there a way to set the timezone for CMS without hacking the code? I notice it seems to be using the server's timezone, but I'd like to be able to host multiple sites (with varying timezones) on the one server.
Any tips would be much appreciated.
Re: Timezone Setting
Posted: Mon Aug 29, 2005 2:34 pm
by Ted
What really shows the time, except for the News module?
Re: Timezone Setting
Posted: Mon Aug 29, 2005 9:15 pm
by nuspace
Exactly

. Well, that and the admin log, which isn't too big of a deal.
So is there a way to specify the time zone for the News module then? I noticed that RSS feeds look like they're published in UTC, which is okay because the RSS reader would figure things out. But if I'm not mistaken the articles themselves seem to reflect the server's time zone?
Re: Timezone Setting
Posted: Mon Aug 29, 2005 9:20 pm
by Ted
To be honest, I don't know an easy way of doing that that I'm aware of...
There would have to be some kind of offset made with mktime, I think.
Re: Timezone Setting
Posted: Mon Aug 29, 2005 10:46 pm
by nuspace
Okay, I'll try to work something out, but any solution I find would probably be just a hack. I think to do it properly this would really need a field in the db and an admin setting. Then anything that reads or displays dates would have to take the tz into account.
Re: Timezone Setting
Posted: Mon Aug 29, 2005 11:11 pm
by Ted
I agree that it's probably a good idea. If you give me some hints on how to modify the dates, I can probably fit that in somewhere.
Re: Timezone Setting
Posted: Tue Aug 30, 2005 12:15 am
by nuspace
The simplest way I can think of is to store all timestamps in GMT. So whenever you call mktime(), subtract the offset in seconds from the timestamp. Conversely, whenever you read a timestamp from the database, add the offset. This way, the user can change their timezone any time and it would still display the correct time.
Internally, the offset is probably best stored in minutes rather than hours, as there are timezones that are a half or even a quarter of an hour off.
Re: Timezone Setting
Posted: Tue Sep 06, 2005 11:57 am
by trick
Use the 'Z' setting on the date function:
http://www.php.net/date
Re: Timezone Setting
Posted: Thu Oct 27, 2005 7:23 pm
by EsquireX
I, too, am attempting to change the timezone on my site only because I want to display the current date and time on my main page. Is this possible?
Re: Timezone Setting
Posted: Wed Apr 18, 2007 9:40 am
by SimonSchaufi
in other CMS it is working like in Joomla. (
http://www.joomla.de)
I will be happy to see the same function in the next version!
In my case: My Website is for Nigeria but the Server is in USA. the time is the one in USA (-7 hours) and not the one in Nigeria.
This is the solution:
$timezone = 1; //(GMT -5:00) EST (U.S. & Canada) The user can set different values here
echo gmdate("d.m.Y H:i:s", time() + 3600*($timezone+date("I")));
date("I") is for summer and winter time and the user should also choose if he is in a country with summer and winter time or not
See
http://de3.php.net/manual/en/function.gmdate.php
Re: Timezone Setting
Posted: Wed Apr 18, 2007 9:37 pm
by Nullig
Re: Timezone Setting
Posted: Thu May 29, 2008 1:49 am
by st3ph3n
Anyone have any luck with this? Sorry if this has been answered elsewhere (or here and I don't understand it!)
I have a server in the states, with my site designed for NZ. We have the News and Calendar modules, I don't care too much about news but the Calendar module relies on the server time, so the current day is often wrong. Is there any way to offset the master clock to line up with us? (GMT+12)
Re: Timezone Setting
Posted: Thu May 29, 2008 2:35 am
by Nullig
If you have access to the .htaccess file, you could try adding:
SetEnv TZ Pacific/Auckland
or
SetEnv TZ NZ
Not sure which one is correct...
Nullig
Re: Timezone Setting
Posted: Thu May 29, 2008 9:32 pm
by st3ph3n
Awesome, I think that did it!

Thanks!
(I used SetEnv TZ Pacific/Auckland)
Re: Timezone Setting
Posted: Fri Jun 06, 2008 3:24 pm
by delfstrom
On my host it didn't work the .htaccess file, but I was able to overcome this by adding the following line to config.php (I put it under the locale setting line)
putenv('TZ=US/Eastern');
Works just fine in the news date/time etc. Change according to your own timezone.