Problem Is Post Timestamp
Topics related to Realistic theme goes here.

TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: Problem Is Post Timestamp

linkPost by TahMiD » Sun Dec 17, 2017 8:25 pm

techubs*net
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: Problem Is Post Timestamp

linkPost by admin » Sun Dec 17, 2017 9:21 pm

My appologies :oops: The duplicate date issue is my fault.
Here is a better code, open /inc/common.php file and replace the realistic_time_ago() and realistic_posted() functions (including the if function_exists check). So delete from line 10 to 65 and add the code below:
// Time ago format function
if ( !function_exists( 'realistic_time_ago' ) ) {
	function realistic_time_ago( $date ) {

		// Array of time period chunks
		$chunks = array(
			array( 60 * 60 * 24 * 365 , esc_html__( 'year', 'realistic' ), esc_html__( 'years', 'realistic' ) ),
			array( 60 * 60 * 24 * 30 , esc_html__( 'month', 'realistic' ), esc_html__( 'months', 'realistic' ) ),
			array( 60 * 60 * 24 * 7, esc_html__( 'week', 'realistic' ), esc_html__( 'weeks', 'realistic' ) ),
			array( 60 * 60 * 24 , esc_html__( 'day', 'realistic' ), esc_html__( 'days', 'realistic' ) ),
			array( 60 * 60 , esc_html__( 'hour', 'realistic' ), esc_html__( 'hours', 'realistic' ) ),
			array( 60 , esc_html__( 'minute', 'realistic' ), esc_html__( 'minutes', 'realistic' ) ),
			array( 1, esc_html__( 'second', 'realistic' ), esc_html__( 'seconds', 'realistic' ) )
		);
	 
		if ( !is_numeric( $date ) ) {
			$time_chunks = explode( ':', str_replace( ' ', ':', $date ) );
			$date_chunks = explode( '-', str_replace( ' ', '-', $date ) );
			$date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
		}
	 
		$current_time = current_time( 'mysql', $gmt = 0 );
		$newer_date = strtotime( $current_time );
	 
		// Difference in seconds
		$since = $newer_date - $date;
	 
		// Something went wrong with date calculation and we ended up with a negative date.
		if ( 0 > $since )
			return esc_html__( 'sometime', 'realistic' );

		//Step one: the first chunk
		for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
			$seconds = $chunks[$i][0];
	 
			// Finding the biggest chunk (if the chunk fits, break)
			if ( ( $count = floor($since / $seconds) ) != 0 )
				break;
		}
	 
		// Set output var
		$output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
	 
	 
		if ( !(int)trim($output) ){
			$output = '0 ' . esc_html__( 'seconds', 'realistic' );
		}
	 
		$output .= esc_html__( ' ago', 'realistic' );
	    return $output;
	}
}

// Display HTML with meta information for the current post-date/time.
if ( !function_exists( 'realistic_posted' ) ) {
    function realistic_posted() {

    	global $post;

		$format = 'ago_format'; // or traditional

		if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {

			$pattern = '<time class="entry-date published" datetime="%1$s" style="display:none;">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';

			// Readable dates
			$date = $format == 'ago_format'? realistic_time_ago( get_post_time('G', true, $post) ): esc_html( get_the_date() );
			$modified_date = $format == 'ago_format'? realistic_time_ago( get_post_modified_time('G', true, $post) ): esc_html( get_the_modified_date() );

			$date_string = sprintf( $pattern,
				esc_attr( get_the_date( 'c' ) ),
				$date,
				esc_attr( get_the_modified_date( 'c' ) ),
				$modified_date
			);

		} else {

			$pattern = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';

			// Readable date
			$date = $format == 'ago_format'? realistic_time_ago( get_post_time('G', true, $post) ): esc_html( get_the_date() );

			$date_string = sprintf( $pattern,
				esc_attr( get_the_date( 'c' ) ),
				$date
			);
		}

		$posted = sprintf(
			_x( '%s', 'post date', 'realistic' ),
			$date_string 
		);

		echo $posted;
	}
}
This code is more SEO friendly (search engine readable ISO 8601 full date/time) and if your post has been update, the update/modified date will be displayed. Also, the display:none; style will hide the publish date so you will get only one date at a time but search engine still get both dates in case they need them.

Actually, this will not fix your issue, but we will be able to compare between the ISO 8601 date/time and the displayed date. If they match, then there is something wrong with your WordPress installation but at least, this will tell us from where we need to start digging :D
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: Problem Is Post Timestamp

linkPost by TahMiD » Sun Dec 17, 2017 10:09 pm

Ok, I will edit that. My wp installation was from GCP click to deploy, and I reinstalled wp. But the ago problem still on there.. I don't know why!
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: Problem Is Post Timestamp

linkPost by TahMiD » Mon Dec 18, 2017 10:58 pm

Yes, After applying the latest update, the default wp timing is working perfectly. But I really need "Time Ago" system, cuz it's more wonderful. Plz, provide me the better time ago code, if possible!
and are you Muslim?
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: Problem Is Post Timestamp

linkPost by admin » Thu Dec 21, 2017 9:51 pm

The "Time ago" format wasn't removed. It's now available as option under Appearance => Customize => General => Date Format
It should be set to "Time ago" by default. I don't know why you have it set to "Site default" :roll:
And yes, I am a muslim! From Tunisia :D
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
TahMiD Borhan

Member Rank
Posts: 41
Joined: Mon Dec 11, 2017 12:37 pm
Display Name: TahMiD Borhan

Re: Problem Is Post Timestamp

linkPost by TahMiD » Thu Dec 21, 2017 10:25 pm

Subhan Allah!. I am Also a Muslim From Bangladesh.
User avatar
Asmi Khalil

Site Admin Rank
Posts: 781
Joined: Fri Jun 26, 2015 7:13 am
Display Name: Asmi Khalil
Location: Tunisia

Re: Problem Is Post Timestamp

linkPost by admin » Thu Dec 21, 2017 10:33 pm

TahMiD wrote:Subhan Allah!. I am Also a Muslim From Bangladesh.
Nice to have you with us my brother :D
I think there is a world market for maybe five computers. - IBM chairman Thomas Watson, 1943
Pascalkit

New Member Rank
Posts: 9
Joined: Sun May 05, 2019 2:16 pm
Display Name: Pascalkit
Location: Bolivia

Problem Is Post Timestamp

linkPost by Pascalkit » Sat May 18, 2019 9:36 pm

Sorry Drake I dont use post formats so have never come across the issue.

Looking at the code in that file have you checked that the audio player used by Suffusion is still available?

Who is online

Users browsing this forum: No registered users and 1 guest

It is currently Tue Jul 16, 2019 10:22 am