Title: How to update &quot;Time Ago&quot; function?
Last modified: August 20, 2016

---

# How to update "Time Ago" function?

 *  [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/)
 * I came across this article [http://techably.com/dynamic-wordpress-time-format/3693/](http://techably.com/dynamic-wordpress-time-format/3693/).
 * It works nicely, so far it displays the time as “Posted 30 minutes ago”, cool.
 * The issue is that I want it to say “Just now” if it was published less than 30
   seconds to 1 minute ago.
    I’d also want to display hours, days, weeks, months,
   and years ago. But this function is very limited, after a certain amount of time
   the regular date is displayed.
 * How can I tweak the code up a bit to accomplish this?…

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [tschoffelen](https://wordpress.org/support/users/tschoffelen/)
 * (@tschoffelen)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301821)
 * 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;
        }
       ```
   
 *  Thread Starter [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301823)
 * No, now all of the dates say Just now 🙁
 *  [tschoffelen](https://wordpress.org/support/users/tschoffelen/)
 * (@tschoffelen)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301824)
 * 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;
        }
       ```
   
 *  Thread Starter [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301826)
 * Works nicely! Thanks!
    Can you help be display “1 Month ago” after 4 weeks has
   past and “2 Months ago” along with years ago?
 *  Thread Starter [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301827)
 * Quick question does the updated time code display “Weeks ago”?
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301829)
 * 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/](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](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.
 *  Thread Starter [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301830)
 * 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?
 *  Thread Starter [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * (@keysuuh)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301831)
 * Jan, I just tried using that technique the most recent post now says “sometime”
   Why is that happening? Do You know?…

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘How to update "Time Ago" function?’ is closed to new replies.

## Tags

 * [ago](https://wordpress.org/support/topic-tag/ago/)
 * [date](https://wordpress.org/support/topic-tag/date/)
 * [display](https://wordpress.org/support/topic-tag/display/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [posted](https://wordpress.org/support/topic-tag/posted/)
 * [published](https://wordpress.org/support/topic-tag/published/)
 * [time](https://wordpress.org/support/topic-tag/time/)

 * 8 replies
 * 3 participants
 * Last reply from: [keysuuh](https://wordpress.org/support/users/keysuuh/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/how-to-update-time-ago-function/#post-3301831)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
