• Hi everyone
    A classical question about how to convert a date in french.
    So I tried different ways but I don’t resolve my problem.
    This is my code :
    <?= date_format($meet_day,"D j F"); ?>
    So I have the date in English but I want to have it in french. I read that we can use date_i18n() but I don’t know how to use it to make it work

    Thanks for help

    • This topic was modified 3 years, 3 months ago by zazzou.
Viewing 1 replies (of 1 total)
  • No idea what format your $meet_day is in but you can start with:

    function dateToFrench($date, $format) 
    {
        $english_days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
        $french_days = array('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche');
        $english_months = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
        $french_months = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'ao?t', 'septembre', 'octobre', 'novembre', 'décembre');
        return str_replace($english_months, $french_months, str_replace($english_days, $french_days, date($format, strtotime($date) ) ) );
    }
    echo dateToFrench('2021-12-03', 'l j F');
Viewing 1 replies (of 1 total)
  • The topic ‘How to convert date in french’ is closed to new replies.