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>‘;
<code></code>
should be
$post_time = get_the_time( 'U' );
$human_time = human_time_diff( $post_time, time() );
$cb_date = sprintf(
'<i class="fa fa-clock-o"></i> <time class="updated" datetime="%s">%s ago</time>',
date( 'Y-m-d H:i:s', $post_time ),
$human_time
);
<code></code>