Replace Comment Date With Text When Comments Older Than Specific Date

This PHP code enables you to display text in replace of the comment date if the comment is older than a specific date. In this example, all comments older than 1 year will display the text “Older Than 1 Year”. All comments less than 1 year old will display the comment date.

Video Demonstration

Here’s a video demo:

There’s 2 code snippets included in this tutorial.

1. The 1st code snippet removes the time and only displays the comment date or the custom text.

date

When comment is older than 1 year:

text

2. The 2nd code snippet doesn’t remove the time so it displays the comment date for comments less than a year old and the text “Older Than 1 Year” inline with the time like you see in the following image:

text

Here’s the code snippets for logged in members:

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.