Display time on posts in Facebook style – By default, most wordpress themes you use have a date – month – year format, but in some cases you want to change the current date and time display. with another style like the date and time display of facebook, what to do? To change the time display style of WordPress posts you need a bit of theme customizer skills!
In the previous article, I showed you WordPress tips on how to create a Facebook Like box for WordPress so that you can design a professional Facebook Like box and you can “insert” anywhere in WordPress by Using Shortcode to continue in this article, I will show you how to display the time on posts in Facebook style!

Show time on posts in Facebook style
To display the same date and time as on facebook, you just need to perform relatively simple steps, just intervene in the Functions.php file to change the date and time type. So to change the date and time style to facebook style what you need to do, let’s learn how to change facebook style date and time in WordPress source code!
First go to Menu Appearance > Click Editor (Editing Tools)

Then you look at the Menu column on the left. Click on the file Functions.php

Then copy the code provided below and paste it before the closing ?> tag is ok!
function timeago( $type = 'post' ) {
$d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
return 'Cách đây'." ".human_time_diff($d('U'), current_time('timestamp')) . " " . __(' trước');
}

After pasting, remember to click Update file> continue you look at the Menu column on the left and you can choose the file content.php or Single.php

Then paste the following code where you want it to appear in your post
<?php echo timeago(); ?>
Depending on the theme you are using, the above code can be pasted into the content.php or Single.php file that you feel is most reasonable. Finally, you save and go to the homepage to choose an article and enjoy the results.
Finally, if you find the article useful, please subscribe to my blog regularly to update the latest articles via Email – Thank you!
