• Resolved mkmazid

    (@mkmazid)


    Hi, actually in the header.php to show the post time there is a below code:

    what i want is to print the post date/time which is coming from “Date Format” and “Time Format” from the wp General Settings

    https://prnt.sc/Y59rubftPboE

    how i do change the function and these 2 steps?

    Thanks

    $date_post = '';
    
    if ( array_key_exists( 'post_date', $the_post ) ) {
    
    	$date = new DateTime( trim( $the_post['post_date'] ) );
    
    	$date_post = date_i18n( $format, $date->getTimestamp() );
    }
    $html .= '<span>' . __( 'Published', 'netsposts' ) . '</span><span>' . ' ' . $date_post . '' . '</span>' . ' ' . '<span>' . __( 'out', 'netsposts' ) . '</span>'
    	     . '  <span>' . NetsPostsHtmlHelper::create_link( $blog_url, $blog_name, $open_link_in_new_tab, 'netsposts-source-link' ) . '</span>
    ';
Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter mkmazid

    (@mkmazid)

    update: i changed the first snippet with the below and now the problem is that for all the posts i have the exact same date printed in the FE :

    could you please help me?

    Thanks

    
    $date_post = '';
    
    if ( array_key_exists( 'post_date', $the_post ) ) {
    
    	$date = new DateTime( trim( $the_post['post_date'] ) );
    
    	$date_post = get_post_time ( 'd-m-Y' );
    
    }
    Plugin Author johnzenausa

    (@johnzenausa)

    Is the shortcode not working?

    Thread Starter mkmazid

    (@mkmazid)

    Hi John. no. the shortcode is working properly .

    My issue is the post date

    Thanks

    • This reply was modified 1 year, 11 months ago by mkmazid.
    Plugin Author johnzenausa

    (@johnzenausa)

    okay thanks

    Thread Starter mkmazid

    (@mkmazid)

    Hi John , what is need is to review this part of code to make possible to me to print the post date with the same config of WP setting

    please check this image:

    https://prnt.sc/Y59rubftPboE

    $date_post = '';
    
    if ( array_key_exists( 'post_date', $the_post ) ) {
    
    	$date = new DateTime( trim( $the_post['post_date'] ) );
    
    	$date_post = date_i18n( $format, $date->getTimestamp() );
    
    
    }
    

    Thanks in evidence

    Plugin Author johnzenausa

    (@johnzenausa)

    Hi @mkmazid,

    Did you try the shortcode parameter

    date_format='n/j/y'

    where you may use any of the following WordPress time codes here: https://www.ads-software.com/support/article/formatting-date-and-time/

    Plugin Author johnzenausa

    (@johnzenausa)

    @mkmazid

    you may also use

    date_format='settings'

    and the plugin will get format from WordPress settings.

    Thread Starter mkmazid

    (@mkmazid)

    Hi John, sorry for the late response. with the

    date_format='settings'

    is it working very good.

    Thanks a lot and i wish you the best.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘date_post’ is closed to new replies.