然而,對於大家另一個PHP日期的問題 - 我有一個英文版本的我的網站,其完美的作品當前代碼:PHP日期錯誤使用代碼當翻譯日期
$article = &$articles[$i];
if($currentdate != date("F Y", strtotime($article->getDate()))) {
$currentdate = date("F Y", strtotime($article->getDate()));
$current_content1 .= "<div class='press-articles-heading'>" . $currentdate . " </div>";
}
基本上,這樣做是拉記錄從數據庫並比較日期,以便月份標題只顯示一次,例如2012年7月,然後所有月份的記錄,然後2012年6月等
如果我使用相同的代碼在非英文版本的網站,我得到了一個錯誤:
$article = &$articles[$i];
if($currentdate != date("F Y", strtotime($article->getDate()))) {
$currentdate = strftime("%B %Y", strtotime($article->getDate()));
$current_content1 .= "<div class='press-articles-heading'>" . $currentdate . "</div>";
}
會發生什麼這裏是我獲得每個數據庫記錄的月頭,儘管他們是相同的。
看不到錯誤在哪裏,有沒有人有任何想法?
任何幫助,非常感謝。
更新
我沒有張貼問題之前嘗試一些東西,但認爲最好把它留出來以保持這個問題很簡單。
我曾嘗試以下操作:
$article = &$articles[$i];
if($currentdate != date("F Y", strtotime($article->getDate()))) {
$translated_date = strftime("%B %Y", strtotime($article->getDate()));
$current_content1 .= "<div class='press-articles-heading'>" . $translated_date . "</div>";
}
但是這並沒有解決它
天才,謝謝! – martincarlin87 2012-08-08 08:52:08