Support

Account

Home Forums Front-end Issues Custom date translation problem

Helping

Custom date translation problem

  • Hi!

    Trying to translate a custom field date into my local language.

    $unixtimestamp = strtotime( get_field('data_evento') );
    echo date_i18n( "l d F, Y", $unixtimestamp );

    This code correctly returns the output in my local language, but it is designed to use the local current date.

    Instead, this other code is what I am currently using to display the custom dates in English:

    if(get_field('data_evento')){
    $datetime = DateTime::createFromFormat('d/m/Y', get_field('data_evento'));
    $data_giorno = $datetime->format( 'D');
    $data_giorno_num = $datetime->format('d');
    $data_mese = $datetime->format('M');	

    I need help merging the two codes… custom date + date_i18n = ?

  • Solved by myself.

    <?php echo date_i18n( 'D', strtotime(date_format($datetime, 'D'))); ?>

    Not sure how to close this post now.

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

You must be logged in to reply to this topic.