如何以法语格式提取日期/时间用于WordPress帖子



我正在写一篇wordpress帖子,其中我想要frech格式的日期/时间,如下所示:

ENGLISH
By FJ
Published April 9, 2019 at 4:05 p.m.
Last updated April 9, 2019 at 4:14 p.m.

FRENCH
Un texte de FJ
Publié le 9 avril 2019 à 16 h 05
Mis à jour le 9 avril 2019 à 16 h 14

我使用以下代码为wordpress帖子提取英语/法语的日期/时间:

<strong><?php if (ICL_LANGUAGE_CODE == 'en') { ?>
        By
    <?php } else { ?>
        Un texte de
    <?php } ?><?php the_author(); ?> </strong><br>
<strong><?php if (ICL_LANGUAGE_CODE == 'en') { ?>
        Published <?php the_time('F j, Y'); ?>
    <?php } else { ?>
        Publié le <?php the_time('j F, Y'); ?>
    <?php } ?> <?php if (ICL_LANGUAGE_CODE == 'en') { ?>
        at  <?php the_time('g:i a'); ?>
    <?php } else { ?>
        à   <?php the_time('g:i a'); ?>
    <?php } ?>  </strong><br>
<strong><?php if (ICL_LANGUAGE_CODE == 'en') { ?>
        Last updated <?php the_modified_time('F j, Y');
    } else { ?>
        Mis à jour le <?php the_modified_time('j F, Y');
    } ?><?php if (ICL_LANGUAGE_CODE == 'en') { ?>
        at <?php the_modified_time('g:i a');
    } else { ?>
        à  <?php the_modified_time('g:i a');
    } ?>  </strong>

上面的代码显示以下 o/p。英语很好,但法语似乎不起作用。

By FJ
Published April 9, 2019 at 4:05 p.m.
Last updated April 9, 2019 at 4:14 p.m.
Un texte de FJ
Publié le avril 9, 2019 à 4:05
Mis à jour le avril 9, 2019 à 5:14

您可以尝试在法语格式的"ifs"上声明不同的日期格式,看起来像这样

<strong><?php if(ICL_LANGUAGE_CODE=='en'){ ?>
By
<?php }else{ ?>
Un texte de
<?php  } ?><?php the_author(); ?> </strong><br>
<strong><?php if(ICL_LANGUAGE_CODE=='en'){ ?>
Published <?php the_time('F j, Y'); ?>
<?php }else{ ?>
Publié le <?php the_time('j F, Y'); ?>
<?php  }  ?> <?php if(ICL_LANGUAGE_CODE=='en'){ ?>
at
<?php }else{ ?>
à
<?php  }  ?> <?php the_time('g:i a'); ?> </strong><br>
<strong><?php if(ICL_LANGUAGE_CODE=='en'){ ?>
Last updated <?php the_modified_time('F j, Y'); ?>
<?php }else{ ?>
Mis à jour le <?php the_modified_time('j F, Y'); ?>
<?php  } ?><?php if(ICL_LANGUAGE_CODE=='en'){ ?>
at
<?php }else{ ?>
à
<?php  }  ?> <?php the_modified_time('g:i a'); ?> </strong>

最新更新