The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Human time difference – won't work Reply To: Human time difference – won't work


I think I have cracked it for you buddy…
W3Schools – Time element
WordPress Codex – get_the_time Function Reference
PHP Manual – Date Function

Your Code
$cb_date = ‘<i class=”fa fa-clock-o”></i> <time class=”updated” datetime=”‘ . human_time_diff(get_the_time(‘U’),current_time(‘timestamp’)) . ‘ago'; ‘”>’ . date_i18n( get_option(‘date_format’), strtotime(human_time_diff(get_the_time(‘U’),current_time(‘timestamp’)))) . ‘</time>‘;

should be
$post_time = get_the_time( 'U' );
$human_time = human_time_diff( $post_time, time() );
$cb_date = sprintf(
'&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; &lt;time class="updated" datetime="%s"&gt;%s ago&lt;/time&gt;',
date( 'Y-m-d H:i:s', $post_time ),

Gist for testing outside of WP