Timezone fixing

0 views
Skip to first unread message

Sam Collett

unread,
Feb 6, 2009, 1:08:05 PM2/6/09
to Pixie
From earlier discussions, working with times / dates can be
problematic if you are on a different time zone than the web server.
Since the time zone can be set for the site ( Admin > Settings >
Pixie ), that information can be used in the /index.php and /admin/
index.php files

Simply look for the line

extract($prefs);

and underneath it put

putenv("TZ=$timezone");

The dates should hopefully be displayed as expected. I tried the PHP 5
method "date_default_timezone_set", but that didn't seem to work
(maybe since the offset is in seconds?). ini_set("date.timezone", "GMT
$timezone"); may also work

There are a few caveats:

- Only tested on Linux web host (not sure if Windows Server will work)
- The site time zone is in the same time zone as the user
- The Daylight Savings Time would have to be manually changed whenever
it comes into effect (I set it to Yes, and the result was that the
times were an hour ahead)

-- Sam
PS My web host is in California and I am in the UK (8 hours behind).
Before the change, news/blog posts would not show until 8 hours had
gone by

Scott

unread,
Feb 8, 2009, 7:57:23 AM2/8/09
to Pixie
Hi Sam
Thanks for this I will give it a try... I was wondering if you know
how this affects the MySQL database. In Pixie we have lots of queries
that look like this:

$rs = safe_rows_start("*", "pixie_dynamic_posts", "page_id =
'$page_id' and public = 'yes' and posted < now() order by posted desc
limit $start,$posts_per_page");

I was wondering if it is PHP that controls the time stored in now()...
I am hoping it is, otherwise it would be extremely confusing.

Lets hope this is heading towards a fix!... if anyone else has
timezone issues please give this a try and post back your findings.

Scott
Reply all
Reply to author
Forward
0 new messages