For me at least, the problem seems to come down to the fact that NOW()
in a MySQL query uses the timezone of the MySQL server (or whatever
you have set the timezone with (e.g. SET SESSION time_zone='+0:00'),
not what the timezone for PHP is (using putenv).
When you insert a dynamic entry, it inserts it as the date and time
according to the timezone of Pixie. Log entries use Unix time and when
you use MySQL queries, the MySQL timezone is used... these could all
end up in different time zones.
There are a few options, but they assume SET SESSION time_zone and
putenv work:
1. Always use Pixie time zone, including for log entries
2. Use UTC time, but store offset in additional field when adding
dynamic entries or events (or other things that allow user entered
dates)
The second option has a benefit of allowing timezones to be set per
user, instead of for (or in addition to) the site... then dates can be
displayed using local user time (user 'A' posts 2009/27/09 10:20 UTC,
user 'B' (in California, GMT -8) sees 2009/27/09 2:20).
It would mean using a method to display the date (e.g. FormatDateTime
($date, $format) - where $date is a UTC date, $format is the format
you want it displayed. Within the method it will use an offset -
either the timezone offset for a user retrieved from the database (if
logged in), or 0 / site time zone). Developers would also have to take
into account that anything involving dates will be UTC.
Perhaps have a utility class, with methods like FormatDateTime (and
maybe other things people may find helpful)?
--Sam