Revision: 326
Updated Code
at July 9, 2006 22:29 by championeer
Updated Code
<?php $myrecentposts = $wpdb->get_results( "SELECT DISTINCT * FROM $wpdb->posts, $wpdb->post2cat ". "WHERE post_date_gmt < UTC_TIMESTAMP() ".//æºæ–‡ä»¶æ¤å¤„为post_date < NOW(),这是将帖å日期与æœåŠ¡å™¨æ‰€åœ¨æ—¶åŒºç›¸æ¯”较,但由于我在ä¸å›½è€Œä½¿ç”¨ç¾Žå›½çš„主机,所以将时区改为了ä¸å›½ï¼Œå¯¼è‡´æœ€æ–°æ–‡ç« æ— æ³•æ˜¾ç¤ºï¼Œå› æ¤æ ¹æ®å¤©ä½‘的建议,将æ¤å¤„改为post_date_gmt < UTC_TIMESTAMP(),å³ä½¿ç”¨GMT时区进行比较 "AND (post_status = 'publish') ". "AND $wpdb->posts.ID = $wpdb->post2cat.post_id ". "AND $wpdb->post2cat.category_id != $side_cat ". "GROUP BY $wpdb->posts.ID ". "ORDER BY post_date DESC ". "LIMIT 10 "); if ($myrecentposts) : foreach ($myrecentposts as $post) : setup_postdata($post); ?>
Revision: 325
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 9, 2006 21:38 by championeer
Initial Code
<?php $myrecentposts = $wpdb->get_results( "SELECT DISTINCT * FROM $wpdb->posts, $wpdb->post2cat ". "WHERE post_date_gmt < UTC_TIMESTAMP() ".//æºæ–‡ä»¶æ¤å¤„为post_date < NOW(),这是将帖å日期与æœåŠ¡å™¨æ‰€åœ¨æ—¶åŒºç›¸æ¯”较,但由于我在ä¸å›½è€Œä½¿ç”¨ç¾Žå›½çš„主机,所以将时区改为了ä¸å›½ï¼Œå¯¼è‡´æœ€æ–°æ–‡ç« æ— æ³•æ˜¾ç¤ºï¼Œå› æ¤æ ¹æ®å¤©ä½‘的建议,将æ¤å¤„改为post_date_gmt < UTC_TIMESTAMP(),å³ä½¿ç”¨UTC时区进行比较 "AND (post_status = 'publish') ". "AND $wpdb->posts.ID = $wpdb->post2cat.post_id ". "AND $wpdb->post2cat.category_id != $side_cat ". "GROUP BY $wpdb->posts.ID ". "ORDER BY post_date DESC ". "LIMIT 10 "); if ($myrecentposts) : foreach ($myrecentposts as $post) : setup_postdata($post); ?>
Initial URL
Initial Description
这个问题出现在home.phpä¸ã€‚ from:天佑 在 home.php ä¸ $myrecentposts 內的 SQL 是用 post_date å’Œ NOW() 作比較. NOW() 這個 function 是會以 server çš„ timezone 讀å–ç¾æ™‚的時間,但 post_date 這個 field çš„ timezone å‰‡æ˜¯ä½ åœ¨ WordPress Admin. panel è¨å®šçš„,兩者是極有機會ä¸åŒï¼Ž 11:25 AM 所以如果 server timezone æ˜¯æ¯”ä½ WordPress è¨å®šçš„ timezone æ—©çš„è©±ï¼Œä½ é‡åˆ°çš„å•é¡Œä¾¿æœƒç™¼ç”Ÿï¼Ž 11:27 AM è¦ä¿®æ”¹å…¶å¯¦å¾ˆç°¡å–®ï¼Œåœ¨ home.php ä¸ï¼Œå°‡ $myrecentposts 內的 WHERE post_date < NOW() 改為 WHERE post_date_gmt < UTC_TIMESTAMP() 便å¯
Initial Title
Broadleaf主题模版的时区问题修æ£ï¼ˆå˜åœ¨äºŽå…¶1.4rc1,2,3版ä¸ï¼‰
Initial Tags
wordpress
Initial Language
PHP