前几周,Google管理员工具jijian91的feed时间格式不正确。看了一下,Google要求的标准格式比较特殊,是这样的:

2008-06-24T12:07:09+08:00

上网查到一篇很老的文章,找到点线索。做如下修改:
在wp-includes/feed-atom.php,找到2处echo get_post_time,改为echo get_post_time(’Y-m-d\TH:i:s\+08:00′, true);
在wp-includes/feed-rss2.php,找到2处mysql2date,改为mysql2date(’Y-m-d\TH:i:s\+08:00′

如此,wordpress的Feed输出时间就正确了。wordpress的这个本地化bug至少2005年就有了,到现在还没改!

这两天,又发现wordpress的文章时间和Google XML Sitemaps插件生成的sitemap文件时间也有问题。时间数值是北京时间,但标注的时区是格林威治时间GMT,比实际早了8个小时。这问题不大,但很恶心,所有的文章发表时间都早了8小时,很容易被搜索引擎误认为是造假。还得改。

改wordpress页面显示时间格式:
在wordpress后台,设置-常规,默认时间格式最后加上+08:00,变为Y-m-d G:i +08:00

改Google XML Sitemaps插件生成的sitemap文件时间格式:
这个麻烦些。插件根本没考虑时区的问题。在wordpress后台的插件页,找到Google XML Sitemaps,点编辑。找到function GetTimestampFromMySql,在return mktime($hour, $min, $sec, $month, $day, $year);之前增加$hour = $hour + 8;。幸亏php的mktime能够自动处理超过24的小时数,否则还得加一堆判断。禁用再启用插件,重新生成Sitemap文件。

至此,wordpress显示和Feed中的时区都正常了。说到底,这是wordpress的本地化做得不彻底。

本文来自http://jijian91.com  原文http://jijian91.com/blog20080626/wordpress-timezone.html

Google

评论

Good.Be the first to comment on this entry.

Post comment

comment has COPYRIGHT too!

Fields in bold are required. Email addresses are never published or distributed.

Some HTML code is allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
URIs must be fully qualified (eg: http://www.domainname.com) and all tags must be properly closed.

Line breaks and paragraphs are automatically converted.

Please keep comments relevant. Off-topic, offensive or inappropriate comments may be edited or removed.