XHanch Studio Log in | Register | Cart

Forum

[Function] Translat...
 
Notifications
Clear all

[Function] Translating date from English to French with PHP

2 Posts
2 Users
0 Likes
1,233 Views
XHanch
(@xhanch-alt)
Posts: 2105
Member Admin
Topic starter
 

Here's a function to translate date from English To French:

<?php
    function dte_fmt_frc($dte){
        $txt_eng = array(
            "Monday", "Tuesday", "Wednesday", "Thursday",
            "Friday", "Saturday", "Sunday", "January",
            "February", "March", "April", "May",
            "June", "July", "August", "September",
            "October", "November", "December"
        );
        $txt_frc = array(
            "Lundi", "Mardi", "Mercredi", "Jeudi",
            "Vendredi", "Samedi", "Dimanche", "Janvier",
            "F&eacute;vrier", "Mars", "Avril", "Mai",
            "Juin", "Juillet", "Ao&ucirc;t", "Septembre",
            "Octobre", "Novembre", "D&eacute;cembre"
        );
        $dte_fmt_frc = str_replace($txt_eng, $txt_frc, $dte);

        $txt_eng = array(
            "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
            "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
            "Aug", "Sep", "Oct", "Nov", "Dec"
        );
        $txt_frc = array(
            "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim",
            "Jan", "F&eacute;v", "Mar", "Avr", "Mai", "Jui",
            "Jui", "Ao&ucirc;", "Sep", "Oct", "Nov", "D&eacute;c"
        );
        $dte_fmt_frc = str_replace($txt_eng, $txt_frc, $dte_fmt_frc);

        return $dte_fmt_frc;
    }
?>

Here's a sample of usage:

<?php
    $dte = date('M d, Y');
    echo dte_fmt_frc($dte);
?>
 
Posted : 22/05/2012 3:58 pm
(@askew)
Posts: 1
New Member
 

thanks alot fro the information and for the code

 
Posted : 08/06/2012 8:38 pm
Share:

× Close Menu