[hermit autoplay=”false” mode=”circulation” preload=”auto”]netease_songlist#:1346053083[/hermit]
其实博主老早就发现这个问题了,也百度了方法,几乎都是让你更改程序或php.ini的时区,但原因并不是这样,下面我们来慢慢分析~
WordPress 的默认时区是 UTC 格林威治时间,我看我后台常规设置中选的就是上海时区,但是就算是将 WordPress 时区调整为上海或 UTC+8 后,前台评论时间显示均还是 UTC 时间,与北京时间仍有 8 小时的时差,而后台评论的时间是正确的,也就是说后台的时区设置对前台评论不起作用。
后来在我翻看数据库时发现了神奇的玩意
这尼玛不是刚好差八小时吗!!!
[qgg_pink]原来dux默认调用的时UTC的时区(如果没错的话),所以这里直接改成以PRC时区的时间就OK了。[/qgg_pink]
[qgg_green]修改地址为:wp-content/themes/dux/widgets 下面直接贴出代码。[/qgg_green]
$sql = "SELECT DISTINCT ID, post_title, post_password, user_id, comment_ID, comment_post_ID, comment_author, comment_date, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,100) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_post_ID!='".$outpost."' AND user_id!='".$outer."' AND comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT $limit"; $comments = $wpdb->get_results($sql); $output = ''; foreach ( $comments as $comment ) { $output .= '<li><a href="'.get_comment_link($comment->comment_ID).'" title="'.$comment->post_title.'上的评论">'._get_the_avatar($user_id=$comment->user_id, $user_email=$comment->comment_author_email).' <strong>'.$comment->comment_author.'</strong> '._get_time_ago( $comment->comment_date ).'说:<br>'.str_replace(' data-original=', ' src=', convert_smilies(strip_tags($comment->com_excerpt))).'</a></li>'; }
OK 完事收工