Vincent
Vincent

Reputation: 137

How can I have the date in french locale

I use this function to have a date in a document

Utilities.formatDate(datejdc, "CEST","EEEE, dd MMMMM yy");

I would like to have the date in French

How can I change the locale in google apps script ?

Upvotes: 4

Views: 2688

Answers (1)

Serge insas
Serge insas

Reputation: 46792

I don't think this is possible directly but it is quite simple to write a script in JS to get that result.

Example :

function frenchDate(date) {
  var month = ['janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'];
  var day = ['dimanche','lundi','mardi','mercredi','jeudi','vendredi','samedi'];
  var m = month[date.getMonth()];
  var d = day[date.getDay()];
  var dateStringFr = d+' '+date.getDate()+' '+m+' '+date.getFullYear();
  return dateStringFr
}

function test(){
Logger.log(frenchDate(new Date()));
}

Logger result : [13-11-18 17:49:33:816 CET] lundi 18 novembre 2013

for details about date methods see this for example

Upvotes: 3

Related Questions