I want to get time difference like "posted 2 days ago".
I know you can use the following to get the difference.
human_time_diff( get_the_time('U'), current_time( 'timestamp' ) ) . ' ago';
But I don't want to use that
date_default_timezone_set('Australia/Melbourne'); // set the time zone
$timestamp = strtotime( $post->post_date ); // get timestamp
$now = time();// get the curren time
$time_passed = $timestamp - $now; // get the differnece
// display time
$min = $time_passed / 60;
if( $min < 60 ) {
return sprintf( avantgardia__( '%s min. ago', 'newspeak' ), intval( $min) );
}
human_time_diff()
does display "2 days", the post just needs to be older than a day, and less than a week. Or do you only want to display days? So "posted 0 days ago", and "posted 1303 days ago"?