PHP : Transform a date in french


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // transforme une date 2007-07-31 en mardi 31 juillet 2007
  2. function neo_date_datefr ($date){
  3. $a_jour = array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
  4. $a_mois = array("","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");
  5.  
  6. $split = preg_split('/-/', $date);
  7. $annee = $split[0];
  8. $mois = round($split[1]);
  9. $jour = round($split[2]);
  10. $hour = substr($split[2], 3);
  11.  
  12. $week = date("w", mktime(12, 0, 0, $mois, $jour, $annee));
  13.  
  14. return $datefr = $a_jour[$week] .' '. $jour .' '. $a_mois[$mois] .' '. $annee;
  15. }

URL: http://www.giacomel.fr

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.