Date translation in french in JavaScript


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

Translate dates in french in JavaScript


Copy this code and paste it in your HTML
  1. var d_names = new Array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi");
  2.  
  3. var m_names = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
  4.  
  5. // date au format : 2010-09-12 18:52:10
  6.  
  7. var d1 = (date).split(' '), d1 = d1[0].split('-'), dateString = d1[1]+'/'+d1[2]+'/'+d1[0], d = new Date(dateString), jour = d.getDay(), jourm = d.getDate(), mois = d.getMonth(), annee = d.getFullYear(), postdate = d_names[jour] + ' ' + jourm + ' ' + m_names[mois] + ' ' + annee;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.