Issues with publish date on RSS Feed

Home Forums Calendar Products Events Calendar PRO Issues with publish date on RSS Feed

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #932438
    cfcpca
    Participant

    Good evening,

    I’m aware of some issues others are having with the published date showing incorrectly on RSS feeds, and unfortunately I’m having the same issue. I’ve seen the following threads already:

    RSS feed wrong time

    RSS feed wrong time

    RSS Feed – Time showing incorrectly.

    I tried implementing the fix suggested in the third linked thread (using -7 for the offset instead of -2 as was posted), and found that the date would then be 49 hours off instead of just 7. Furthermore after some additional testing I found that I was finding three different times depending on what I used to view the feed.

    http://cfcpca.org/events/category/featured/feed/

    Viewing the above link in chrome shows the raw feed data and I see the correct date/time. Viewing it in Firefox shows the time 7 hours behind what Chrome does and viewing it with an online feed reader from SimplePie shows it 8 hours behind what Chrome does, and therefore 1 hour behind what Firefox is showing.

    Any assistance would be greatly appreciated in fixing the feed issues we’re having here. Thanks!

    #933099
    Brook
    Participant

    Howdy cfcpa,

    I would be happy to help you with that. What Chrome is showing is the raw data. It is saying that the “MOPS” event will take place at 9am UTC. It sounds like you are in the mountain time zone though, so Firefox is show the time for UTC -7.

    What are your timezone settings like in WP Admin > Settings > General. There should be a drop down called timezone, and it applies to the timezone for your entire WP site. What is that set to?

    Please let me know if you have any questions of your own. Thanks!

    – Brook

    #933327
    cfcpca
    Participant

    The time zone is currently set to Phoenix.

    #933925
    Brook
    Participant

    Thanks cfcpa. Upon further experimentation I have been able to reproduce this issue as a bug in our plugin. I am going to get this logged so the developers can fix it.

    In the mean time you could fix this by attaching a function to ‘get_post_time’ that behaves like our function ‘event_date_to_pubDate’:

    [php]function event_date_to_pubDate( $time, $d, $gmt ) {
    global $post;

    if ( isset($post) && $post->post_type == TribeEvents::POSTTYPE && is_feed() && $gmt ) {
    $time = tribe_get_start_date( $post->ID, false, $d );
    $time = mysql2date( $d, $time );
    }

    return $time;
    }[/php]

    Only set the variable $gmt to your local timezone by default.

    I am sorry that you are experiencing a bug. Let me know if you have any questions. Thanks!

    – Brook

    #933926
    Brook
    Participant

    [comment deleted]

    #934719
    cfcpca
    Participant

    Brook,

    Thanks for looking into it. So you’re saying I just need to add a filter to get_post_time that uses the function you linked? Like so:

    add_filter( 'get_post_time', 'cfc_event_date_to_pubDate', 20 , 3 );
    function cfc_event_date_to_pubDate( $time, $d, $gmt ) {
      global $post;
    
      if ( isset($post) && $post->post_type == TribeEvents::POSTTYPE && is_feed() && $gmt ) {
          $time = tribe_get_start_date( $post->ID, false, $d );
          $time = mysql2date( $d, $time );
      }
    
      return $time;
    }
    #934889
    Brook
    Participant

    Hello Cfc,

    That is basically exactly what I mean. However, upon further inspection I realized that more is required. You would actually have to convert the date value’s timezone before passing it mysql2date(), which expects the timezone to be GMT. That is the crux of the issue.

    This will require a little more development. I might be able to write something up tomorrow, but it’s also possible that in the end we will have to wait for this bug to be patched in the plugin. I will let you know tomorrow.

    Cheers!

    #935546
    Brook
    Participant

    Howdy again cfc,

    This snippet should do the trick. Just make sure the offset is correct. You can add or subtract hours with it.

    [php]
    add_filter( ‘get_post_time’, ‘events_rss2_gmt_pubdate_correction’, 20 , 3 );

    function events_rss2_gmt_pubdate_correction($time, $d, $gmt) {

    global $post;

    // Amount of hours to change, equals GMT offset
    $offset = -7;

    if ( $post->post_type === TribeEvents::POSTTYPE && is_feed() ) {

    $time = new DateTime( tribe_get_start_date( $post->ID, false, $d ) );
    $time->modify( $offset.’ hour’ );
    $time = $time->format( TribeDateUtils::DBDATETIMEFORMAT );
    $time = mysql2date( $d, $time );

    }

    return $time;
    }
    [/php]

    Did that work? I appreciate your patience through this. Let me know if that helps, or if I can assist in some other way. Cheers!

    – Brook

    #939638
    Brook
    Participant

    Since this topic has gone for a couple weeks without a response I am going to archive it. If you need anything else though, or even need to continue this at a future date, please feel free to open a new topic. We will be happy to help. Cheers!

    – Brook

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Issues with publish date on RSS Feed’ is closed to new replies.