Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1093028
    knowmates
    Participant

    Hi there,

    I want to change the date format in X to German standard. I’ve changed in the WP settings which is doing fine for most of the site. No I#ve noticed that the date format for the comments is wrong: 02.25.2016 should be 25.02.2016

    In this Post (https://community.theme.co/forums/topic/change-date-format-2/) I’ve found the following code which I had to add to child themes functions.php:

    add_filter( 'get_comment_date', 'change_comment_date_format' );    
    function change_comment_date_format( $d ) {
        $d = date("d/m/Y");    
        return $d;
    }    

    This results only the current date of today but not the correct date format from this comment. How can I change it?

    #1093078
    Christopher
    Moderator

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1096647
    knowmates
    Participant
    This reply has been marked as private.
    #1096684
    Rue Nel
    Moderator

    Hello There,

    Thanks for providing the url of the page. To resolve this issue, please insert this following code in your child theme’s functions.php file.

    function x_renew_comment( $comment, $args, $depth ) {
    
      $GLOBALS['comment'] = $comment;
      switch ( $comment->comment_type ) :
        case 'pingback' :  // 1
        case 'trackback' : // 1
      ?>
      <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
        <p><?php _e( 'Pingback:', '__x__' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', '__x__' ), '<span class="edit-link">', '</span>' ); ?></p>
      <?php
          break;
        default : // 2
        GLOBAL $post;
        if ( X_WOOCOMMERCE_IS_ACTIVE ) :
          $rating = esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) );
        endif;
        if ( x_is_product() ) {
          $comment_avatar = get_avatar( $comment, 240 );
        } else {
          $comment_avatar = get_avatar( $comment, 120 );
        }
      ?>
      <li id="li-comment-<?php comment_ID(); ?>" <?php comment_class(); ?>>
        <article id="comment-<?php comment_ID(); ?>" class="comment">
          <?php
          printf( '<div class="x-comment-img">%s</div>',
            '<span class="avatar-wrap cf">' . $comment_avatar . '</span>'
          );
          ?>
          <?php if ( ! x_is_product() ) : ?>
          <div class="x-reply">
            <?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span class="comment-reply-link-after"><i class="x-icon-reply" data-x-icon=""></i></span>', '__x__' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
          </div>
          <?php endif; ?>
          <div class="x-comment-wrap">
            <header class="x-comment-header">
              <?php
              printf( '<cite class="x-comment-author">%1$s</cite>',
                get_comment_author_link()
              );
              if ( x_is_product() && get_option('woocommerce_enable_review_rating') == 'yes' ) : ?>
                <div class="star-rating-container">
                  <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo sprintf( __( 'Rated %d out of 5', '__x__' ), $rating ) ?>">
                    <span style="width:<?php echo ( intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ) / 5 ) * 100; ?>%"><strong itemprop="ratingValue"><?php echo intval( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?></strong> <?php _e( 'out of 5', '__x__' ); ?></span>
                  </div>
                </div>
              <?php endif;
              printf( '<div><a href="%1$s" class="x-comment-time"><time datetime="%2$s">%3$s</time></a></div>',
                esc_url( get_comment_link( $comment->comment_ID ) ),
                get_comment_time( 'c' ),
                sprintf( __( '%1$s at %2$s', '__x__' ),
                  get_comment_date( 'd/m/Y' ),
                  get_comment_time()
                )
              );
              edit_comment_link( __( '<i class="x-icon-edit" data-x-icon=""></i> Edit', '__x__' ) );
              ?>
            </header>
            <?php if ( '0' == $comment->comment_approved ) : ?>
              <p class="x-comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', '__x__' ); ?></p>
            <?php endif; ?>
            <section class="x-comment-content">
              <?php comment_text(); ?>
            </section>
          </div>
        </article>
      <?php
          break;
      endswitch;
    
    }

    Please copy the raw code from here (http://pastebin.com/hugEppXM) to preserve the unicode html entities or the data-x-icon value.

    We would loved to know if this has work for you. Thank you.

    #1098307
    knowmates
    Participant

    Yeah! Solved my problem 🙂 I Only changed get_comment_date( ‘d/m/Y’ ) to get_comment_date( ‘d.m.Y’ ) for German format

    Thank you!

    #1098308
    Paul R
    Moderator

    You’re welcome! 🙂

  • <script> jQuery(function($){ $("#no-reply-1093028 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>