How do I set up & ldquo; Time Ago & rdquo; on the Wordpress text box?


I’d like to add a text line saying that “The latest event has been ended 3 days ago”

And the part “3 days ago” will automatically change as the day goes by, e.g. 1 month ago and so on…. Is there any shortcode plugin I can use for this? Or any method?

I found this plugin but it seems to work with post/page/comment time. Not for a text line.


If you want to use a custom timestamp for the event and know how to write basic php code, you can use the php's DateTime::diff method or better, use Carbon to get the difference between your custom timestamp and today's date.

Examples in the linked docs should suffice in understanding and to echo the difference between the dates. Now, use that inside WordPress, write that code in a function in your theme's functions.php file and return the value to create a shortcode for the difference.

function eventdiff_func( $atts ) {

    // write code which calculates the difference here and store it in $diff

    return $diff;
add_shortcode( 'event_diff', 'eventdiff_func' );

Now you can use the [event_diff] shortcode whereever you'd like to output the difference that you calculated.