将wordpress中的日期格式更改为相对日期


Change date format in wordpress to relative date

这里需要一点帮助,因为我不太熟悉PHP。我有两个帖子类型,一个是显示日期的"x time ago"格式,一个是显示传统的wordpress日期格式。

我在我的wordpress主题中发现了这一行,它在我的帖子上显示传统格式。

$postheader .= '<abbr class="published" title="' . get_the_time('c') . '">' . get_the_time( get_option('date_format') ) . '</abbr></span>';

现在这个主题已经有一个预先编写的函数来显示x分钟,天,周,年前的时间,定义为'%s',它正在下面的代码中使用

<abbr class="published" title="<?php the_time('c') ?>"><?php printf( __('%s', 'arras'), arras_posted_on( false ) ) ?></abbr> | <a href="<?php comments_link() ?>"><?php comments_number() ?></a>
我的问题是……如何修改第一个代码以显示"x时间以前"的格式,就像第二个代码中使用的格式一样?我试图粘贴完全相同的行,它使我的页面在重新加载时变成空白。

试试下面的代码:

$postheader .= '<abbr class="published" title="' . arras_posted_on( false ) . '">' . arras_posted_on( false ) . '</abbr></span>';