[Resolved] Customization for the date

  • Author
    Posts
  • #4803

    rawn
    Participant

    Hello, how do I change the format for the date from D/m/y to m/d/y?

    #4804

    Andrew Misplon
    Keymaster

    Hi rawn

    Thanks for posting. It isn’t possible from within theme settings, it’ll take some custom development. Please, can you confirm which theme you’re using.

    In the mean time, please, go to Plugins > Add New and install Code Snippets.

    #4805

    rawn
    Participant

    Puro Premium

    #4806

    Andrew Misplon
    Keymaster

    Super. Thanks for your support. Once Code Snippets is activated, go to Snippets > Add New and create a new snippet, you can name it as you’d like. Insert the following in the snippet body:

    if ( ! function_exists( 'puro_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time, author, comment count and categories.
     */
    function puro_posted_on() {
    
    	if ( is_sticky() && is_home() && ! is_paged() ) {
    		echo '<span class="featured-post">' . __( 'Sticky', 'puro' ) . '</span>';
    	}
    
    	if ( is_home() && siteorigin_setting('blog_post_date') || is_archive() && siteorigin_setting('blog_post_date') || is_search() && siteorigin_setting('blog_post_date') ) {
    		echo '<span class="entry-date"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date( 'F j Y' ) ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span></a>';
    	}
    
    	if ( is_single() && siteorigin_setting('blog_post_date') ) {
    		echo '<span class="entry-date"><time class="published" datetime="' . esc_attr( get_the_date( 'c' ) ) . '">' . esc_html( get_the_date( 'F j Y' ) ) . '</time><time class="updated" datetime="' . esc_attr( get_the_modified_date( 'c' ) ) . '">' . esc_html( get_the_modified_date() ) . '</time></span>';
    	}
    
    	if ( siteorigin_setting('blog_post_author') ) {
    		echo '<span class="byline"><span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '" rel="author">' . esc_html( get_the_author() ) . '</a></span></span>';
    	}
    
    	if ( has_category() && siteorigin_setting('blog_post_cats') ) {
    		echo '<span class="cat-links">' . get_the_category_list( __( ', ', 'puro' ) ) . '</span>';
    	}
    
    	if ( has_tag() && siteorigin_setting('blog_post_tags') ) {
    		echo '<span class="tags-links">' . get_the_tag_list( '', __( ', ', 'puro' ) ) . '</span>';
    	}
    
    	if ( comments_open() && siteorigin_setting('blog_post_comment_count') ) { 
    		echo '<span class="comments-link">';
      		comments_popup_link( __( 'Leave a comment', 'puro' ), __( '1 Comment', 'puro' ), __( '% Comments', 'puro' ) );
      		echo '</span>';
    	}
    
    }
    endif;

    Finally, NB: click the radio button to only run this snippet on the side front-end. Then, save changes and activate.

    #4807

    Andrew Misplon
    Keymaster

    For a nicely formatted version of the snippet, please, see: http://pastebin.com/raw/sxB98Y5P.

    #4808

    rawn
    Participant

    You are the best! This one little thing kept me from using the theme for so long, any chance it can be added to the customizer in a future release?

    #4809

    Andrew Misplon
    Keymaster

    Super 🙂 Really glad I could help out.

    Sure, it’s been requested a few times so I can see there is a desire/demand to have control over the date output. I’ll log this as an enhancement request and investigate how to best implement it in an update soon.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Scroll to top