Bug: RSS Date Displays in UTC – has patch
-
Below is a patch that will allow hungryfeed to grab the local timezone set for the blog, and change the date / time to match instead of by default displaying the UTC timestamp.
Let me know if you have any questions!
Index: hungryfeed.php =================================================================== --- hungryfeed.php (revision 1365103) +++ hungryfeed.php (working copy) @@ -390,7 +390,7 @@ 'description' => $description, 'content' => $content, 'author' => $author_name, - 'post_date' => $item->get_date($date_format), + 'post_date' => hungryfeed_converttolocaltime($item->get_date($date_format),$date_format), 'source_title' => $source_title, 'source_permalink' => $source_permalink, 'latitude' => $item->get_latitude(), @@ -419,8 +419,8 @@ echo '<div class="hungryfeed_item_content">' . $content . "</div>\n"; if ($author_name && in_array("author",$item_fields)) echo '<div class="hungryfeed_item_author">Author: ' . $author_name . "</div>\n"; - if ($item->get_date() && in_array("date",$item_fields)) - echo '<div class="hungryfeed_item_date">Posted: ' . $item->get_date($date_format) . "</div>\n"; + if (hungryfeed_converttolocaltime($item->get_date(),$date_format) && in_array("date",$item_fields)) + echo '<div class="hungryfeed_item_date">Posted: ' . hungryfeed_converttolocaltime($item->get_date($date_format),$date_format) . "</div>\n"; echo "</div>\n"; } @@ -613,3 +613,17 @@ $qvars[] = 'hf_page'; // used by pagination return $qvars; } + +/** + * converts the UTC date from the RSS feed into the local date + * set on the settings page + * + * @param string UTC date pulled from rss + * @param string date format string pulled from shortcode + */ +function hungryfeed_converttolocaltime ( $time, $date_format ) { + $ts = strtotime($time); + $tz = get_option('timezone_string'); + if ( $tz ) date_default_timezone_set( $tz ); + return get_date_from_gmt(gmdate('Y-m-d H:i:s',$ts),$date_format); +}
- The topic ‘Bug: RSS Date Displays in UTC – has patch’ is closed to new replies.