我在寻找相同答案时发现了您的问题。我做了一个函数,让我可以human_time_diff用这个简单的代码块巧妙地调用:<?php human_friendly_date(); ?>. 您的问题的答案在倒数第二行代码中。
function human_friendly_date() {
global $post;
$today = date("r");
$postdate = get_the_time('r');
$difference = round((strtotime($today) - strtotime($postdate))/(24*60*60),0);
if ($difference >= 7) {
$humandate = the_time('F j, Y');
} else {
$humandate = human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';
}
$humandate = str_replace('mins', 'minutes', $humandate);
echo $humandate;
}