Home Forums Inside This WordPress Site Function get_date_from_gmt() returns GMT time, if called from bbPress page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #2271
    Udar Gromov

    I am looking for a solution to this problem.

    WordPress function get_date_from_gmt($post->post_modified_gmt) usually returns a date and time in your site time zone. However, if this function is called from bbPress page, it always returns GMT time.

    Udar Gromov

    I started to dig dipper. Function depends on GMT offset returned by get_option(‘gmt_offset’). When called from bbPress this function returns nothing. As a result get_date_from_gmt() always returns GMT time.

    Here is a chart:

    function get_date_from_gmt() is in wp-includesformatting.php

    function get_option() is in wp-includesfunctions.php

    Udar Gromov

    A TEMP solution for this problem is to hard-coded your offset fix in


    // ***** 2011-03-08 TU 23:09  Use -5, if no offset returned *****
    // $string_localtime = gmdate($format, $string_time +
    $myOffset = (get_option('gmt_offset'))? get_option('gmt_offset'): -5;
    $string_localtime = gmdate($format, $string_time + $myOffset*3600);

    Udar Gromov

    Problem solved using free NetBeans IDE 6.9.1 with Xdebug 2.1.0. Thank you!

    All I had to do was to add one line of code to ‘bbpressmy-templatesMYfunctions.php’ file:

    ‘add_filter( ‘pre_option_gmt_offset’,’wp_timezone_override_offset’ );’

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.