0
我正在嘗試更改日期,使其在2天前或30分鐘前顯示。我知道我可以使用人類時間差異,但我不知道如何正確地將它添加到我的網站。每次我嘗試添加它時,都會出現語法錯誤。我正在使用報紙主題。我發現在我的主題文件中獲取日期的代碼,有誰知道我如何更改代碼,以便包含人類時差?更改日期爲人類時間差異
*這個問題不是爲什麼我得到一個語法錯誤。我知道爲什麼,因爲我在代碼中添加了人爲錯誤的時間差異。我不是最好的編碼,這就是爲什麼我要求幫助正確添加它。
從主題代碼
function get_date($show_stars_on_review = true) {
$visibility_class = '';
if (td_util::get_option('tds_m_show_date') == 'hide') {
$visibility_class = ' td-visibility-hidden';
}
$buffy = '';
if ($this->is_review and $show_stars_on_review === true) {
//if review show stars
$buffy .= '<div class="entry-review-stars">';
$buffy .= td_review::render_stars($this->td_review);
$buffy .= '</div>';
} else {
if (td_util::get_option('tds_m_show_date') != 'hide') {
$td_article_date_unix = get_the_time('U', $this->post->ID);
$buffy .= '<span class="td-post-date">';
$buffy .= '<time class="entry-date updated td-module-date' . $visibility_class . '" datetime="' . date(DATE_W3C, $td_article_date_unix) . '" >' . get_the_time(get_option('date_format'), $this->post->ID) . '</time>';
$buffy .= '</span>';
}
}
return $buffy;
}
什麼是你得到的語法錯誤? – Ryan
'$ td_article_date_unix = get_the_time('U',current_time('timestamp'$ this-> post-> ID));'你的問題就在這一行,一個語法錯誤,你有*意外的變量*錯誤 - 在'$ this-> post-> ID'之前需要某種分隔符。但是我不明白你想在那裏做什麼,因爲'get_the_time()'只有兩個參數,並且它不會感覺要將post-ID作爲'current_time()'的第二個參數傳遞。請查閱這些WP功能的文檔。 – Qirel
[PHP Parse/Syntax Errors;和如何解決它們?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Qirel