facebook transparent twitter
Go Back  

SawFirst Forum

> SawFirst - About Your Virtual Presence > Websites

Websites Let us know about your website or any other website you find helpful, here.

Reply
 
Thread Tools
  #1  
Old 07-27-2020, 12:15 AM
Pretty Girl's Avatar
Pretty Girl Pretty Girl is offline
POST ADDICT
 
Join Date: Jul 2019
Location: Manila
Posts: 1,143
Default Change WordPress date format to posted hour ago

Some people may prefer to have so-called “time ago” format in the similar way to Twitter and Facebook style like posted “10 minutes ago”, “1 hour ago”, “3 hours ago”, etc…


for that


add these lines to your functions php file fo your theme
Code:
/* Function which displays your post date in time ago format */
function sawfirst_time_ago() {
	return human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ).' '.__( 'ago' );
}



then replace the date code in your theme with tthis
Code:
<?php echo sawfirst_time_ago(); /* post date in time ago format */ ?>

that's all!!!
__________________
Reply With Quote
Reply

Tags
ago, change, date, format, hour, wordpress
Thread Tools



CONTACT US
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.