Choose the language of the date field

Support General Choose the language of the date fieldResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10516
    Benjamin PichonnazBenjamin Pichonnaz
    Participant

    Hello, I would like the format of the date is displayed in French and not in English, is it possible?

    rwmb_the_value(rw_date_prochaine_ceremonie, array('format' => 'j F Y')

    #10535
    Anh TranAnh Tran
    Keymaster

    Yes, that's possible. To output the date in a different format, please use this code:

    rwmb_the_value( $field_id, array( 'format' => 'F j, Y' ) );

    #10540
    Benjamin PichonnazBenjamin Pichonnaz
    Participant

    Thank you Anh Tran, I misspoke, sorry, I would like to translate the months, not change the format.

    #10570
    Anh TranAnh Tran
    Keymaster

    I got it. Please use the date_i18n function as follows:

    $date = get_post_meta( get_the_ID(), 'field_id', true );
    echo date_i18n( 'F j, Y', $date );

    For more info, please check this docs.

    #34071
    LeghLegh
    Participant

    Hi Ahn Tran,

    I would like to do the same but inside views. I cannot find the way to use it with Twig environments, can you help for this please ?

    Thanks in advance.

    #34074
    LeghLegh
    Participant

    Hi Ahn Tran,

    Finally, i've found the working solution right here on the forum:
    https://support.metabox.io/topic/date-field-output-not-localized/

    Thanks !

    #39202
    vicento@mac.com[email protected]
    Participant

    Hi Han Tran,
    thanks for your reply.

    Your code only return the current date in french format, not the date field content in french format.
    How can we make it work ?

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