Duplicated date

Support General Duplicated dateResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27824
    info@ceescoenen.nl[email protected]
    Participant

    Why I get duplicated data? I will retrieve a field 'datum' and formats the date:

    Friday 7 May 2021Datum: Friday 7 May 2021

    <?php
    $field_id = 'datum';
    $value = rwmb_the_value( $field_id, array( 'format' => 'l j F Y' ) );
    echo "Datum: " . $value ;
    ?>

    #27830
    Long NguyenLong Nguyen
    Moderator

    Hi Cees,

    The helper function rwmb_the_value() does not need to use the echo, it outputs the content of the field. Your code should change to this

    <?php
    $field_id = 'datum';
    ?>
    <span><?php  echo "Datum: "?></span><?php rwmb_the_value( $field_id, array( 'format' => 'l j F Y' ) );
    ?>

    Refer to this topic https://support.metabox.io/topic/why-does-echo-rwmb_the_value-display-a-value-twice/

    #27843
    info@ceescoenen.nl[email protected]
    Participant

    Do this only work when : Save value as timestamp?

    #27871
    Long NguyenLong Nguyen
    Moderator

    Hi,

    If you use the settings timestamp to save value as timestamp, you can use the helper function rwmb_meta().

    $value = rwmb_meta( 'datum' );
    echo 'Datum: ' . date( 'F j, Y', $value );

    Get more details on the documentation https://docs.metabox.io/fields/date/#template-usage

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.