I haven’t really tested it, but I think this should it:
add_filter('the_time', 'dynamictime');
function dynamictime() {
global $post;
$date = $post->post_date;
$time = get_post_time('G', true, $post);
$mytime = time() - $time;
if($mytime > 60){
$mytimestamp = __('Just now');
}else{
$mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
}
return $mytimestamp;
}
No, now all of the dates say Just now 🙁
Sorry, I made a mistake, it should be if($mytime < 6){, as shown below:
add_filter('the_time', 'dynamictime');
function dynamictime() {
global $post;
$date = $post->post_date;
$time = get_post_time('G', true, $post);
$mytime = time() - $time;
if($mytime < 60){
$mytimestamp = __('Just now');
}else{
$mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
}
return $mytimestamp;
}
Works nicely! Thanks!
Can you help be display “1 Month ago” after 4 weeks has past and “2 Months ago” along with years ago?
Quick question does the updated time code display “Weeks ago”?
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
I’ve not visited it recently but I think this post may be what you are looking for.
http://www.jasonbobich.com/wordpress/a-better-way-to-add-time-ago-to-your-wordpress-theme/
It was an answer from an earlier post. 😉
http://wordpress.org/support/topic/human_time_diff-for-years-ago?replies=3
Edit: Not sure it does weeks though, but that post is a good start.
Jan, I tried that before 🙂 The notes say “Where you see ‘themeblvd’ below, you’d want to replace those with whatever term you’re using in your theme to provide support for localization.” But I have no idea what that is or how to do it…
So I tried looking for another technique.
Can you help me with that?
Jan, I just tried using that technique the most recent post now says “sometime” Why is that happening? Do You know?…