Skip to:
Content
Pages
Categories
Search
Top
Bottom

GMT Offset

  • I’ve been playing with bbPress for a few days and noticed that when I started posting the time was set all wrong and the posts I imported were dated wrong (only ones from that day).

    Since I’m in South Australia (+9.5 GMT) I had set the gmt_offset option in the admin interface to 9.5 to accomodate my differences but it wouldn’t set the post date/time to my timezone when posting.

    The only way around it was to modify the bb_current_time function and change this line:

    $d = gmdate(‘Y-m-d H:i:s’);

    to this:

    $d = gmdate(‘Y-m-d H:i:s’, time() + 3600*(bb_get_option(‘gmt_offset’)+date(“I”)));

    So that it actually uses the GMT offset.

    Of course, doing this only means that current posts are displayed at the right time but previous ones are wrong because they’re all set to the current time when posted and the system then adds 9.5hrs onto them when being read.

    I’m assuming either I’ve missed something in the config or the time option just isn’t using the gmt_offset value from the db for anything.

    Can someone confirm or refute this please? I’d like to be able to change it back and do it the proper way if possible.

Viewing 6 replies - 1 through 6 (of 6 total)
  • On thinking about it a bit further, I went back to my SQL posts and kludged a statement which removes 9.5 hours from the various date fields that populate the bbpress database.

    On restoring everything back, it’s ok now.

    Where can I find the bb_current_time function?

    Also could you post the SQL statement you used to fix existing date fields in the db? Thanks.

    bb_current_time is in the functions file inside bb-includes directory. But you probably should touch that otherwise when you update bbpress, it will break again. :)

    The SQL I used was just an interval clause…i.e. if I was going to import my current forums I would use something like:

    SELECT ID, Body, DateCreated – interval ‘9 30’ hour_minute FROM current_forum_whatever

    This takes the date field and drops 9.5 hours off, coincidentally, my time zone.

    You could probably adapt this to an ‘update’ statement to change what’s already in your database, eg:

    UPDATE bb_topics SET DateCreated=(SELECT DateCreated – interval ‘9 30’ hour_minute);

    I haven’t tested it but it probably wouldn’t be too far wrong.

    “bb_current_time is in the functions file inside bb-includes directory. But you probably should touch that otherwise when you update bbpress, it will break again. :)

    Tell me about it — I’ve already hacked another core file which has to be re-tweaked every upgrade…

    BTW isn’t this a bug really?

    Hmmm, your fix caused a bit of breakage for me — time zone is +1, but for some reason two hours were added to the time stamp, resulting in a “freshness” of -1 year! (i.e., the timestamp was now in the future.

    Setting my time offset in General Settings to zero results in the correct time (GMT+1) being shown (server is on UTC btw), but the freshness is still -1 year lol.


    tnts
    Participant

    @tnts

    I wanted to use absolute time instead of relative also, but I noticed the UTC offset doesn’t have any effect on any timestamps. Is this still the only solution or have there been any new workarounds invented? I’m using bbPress 0.9.0.2 and WordPress 2.5.1

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar