This post has already been read 27 times!
WordPress has a built-in function to display relative time in a human-readable format just like Facebook.
For example, instead of your posts displaying, “Posted on January 01 at 00.00am,” you could display, “Posted 3 hours ago.”
I’ll show you how to update your theme to take advantage of the human time diff() function and change the timestamp on your posts.
Using your FTP software (I’m using FileZilla FTP), go into your /themes folder, choose the theme you’re using. Look for single.php file. Open the file using file editor software.
Look for the line that has <?php the_time(); ?> or <?php get_the_time(); ?> function.
Just replace that with this:
<?php echo ‘Posted ‘ . human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago ‘; ?>
After that, save your file and refresh your single post to preview changes.
If it successful and no error encountered, the timestamp will look like this:
You can change the word ‘Posted‘ inside the function to any word you desire or using Ascii characters instead. It’s up to you how you want to style it.
That’s the easiest way to change your timestamp on your single post template. The other method without touching any codes in your php file is by using relative date or time plugin. You can find that by searching at WordPress.org plugins directory.
The other one is by editing and adding codes in your functions.php file. This kind of method is not recommended to anyone with less experience when it comes to complex editing. You might ended with a blank page or other unknown errors.
Comment below if you’re having trouble with this tutorial. I can’t promise you anything, but I will try to help as far as I can.