PHPascal.com

PHPAscal rouge2 (Version bleu)


Programmation web CSS HTML PHP Jquery Javascript Wordpresse RSS SQL SSH, serveur linux Outils
  PHPascal a 147 articles


Recherche


cheap nike nfl jerseysWholesale cheap nfl jerseyscheap jerseys online from chinacheap nfl jerseys free shippingwholesale nba jerseysWholesale cheap nhl jerseyscheap nhl jerseys onlinecheap nba basketball jerseys

Valid HTML 5

Programmation web / PHP / Afficher une date en français

Fonction pour formater une date en français

Fonction pour formater une date en français en PHP.

Voici la fonction tout simple a prendre tel quel permet de convertir la date.  Pour l'affichage en format texte en français ou en anglais.

De : 2010-12-21 14:40:15 vers -> mardi 21 décembre 2010 à 14:40:15


/**
 * formater une date en français ou en anglais
 *
 * affichage date en francais ou en anglais
 * recois une date au format : 2008-12-01 11:16:53
 * et le renvoie au format : 1 décembre 2008 à 11:16:53
 *
 * Exemple %A %d %B %Y à %H:%M:%S  -> Monday 13 June 2011 à 16:13:26
 *
 * http://www.phpascal.com/programmation-web/PHP/date_formater_en_francais.html
 *
 * @param $date = date au format Y-m-d H:i:s
 * @author PHPascal.com
 * @since 2011-06-28 à 16:17:29
 * @return string
 */
function aff_date($date,$lang = 'fr',$format_fr="%d %B %Y", $format_en ="%B %d, %Y")
{
    $date_formatee = "";
   
    $format = $format_fr;
    if ($lang == 'en') $format = $format_en;
               
               
    if ($lang == 'fr') setlocale(LC_TIME, "fr_FR");
           
    $date_strtotime = strtotime($date);
    $date_formatee = strftime ($format,$date_strtotime);
    return $date_formatee;

}
Article écrit le 21 décembre 2010
Article modifié le 28 juin 2011

Autres articles sous la même catégorie


Pascal Dubreuil | © PHPascal.com 2024
Temps d'exécution : 0.0127 sec
Imprimer le 29 March 2024 - 04:24:54
par Pascal Dubreuil organisateur du Marathon roller du Canada