Answer the question
In order to leave comments, you need to log in
How to set Russian locale in Utilites.formatDate()?
Good afternoon. The task is to get the "May-2020" format string in Google Apps Script via Utilities.formatDate() . I do it like this:
var newSheetname = Utilities.formatDate(new Date(), "GMT+3", "MMM-d"); // May-2020
Answer the question
In order to leave comments, you need to log in
I don't remember Utilities
locales being supported.
For V8 you can useDateTimeFormat
function myFormatDate(date) {
const y = new Intl.DateTimeFormat('ru',{
year: 'numeric'
}).format(date)
const m = new Intl.DateTimeFormat('ru',{
month: 'long'
}).format(date)
return `${m}-${y}`
}
function test(){
const date = new Date();
console.log(Utilities.formatDate(date, "GMT+3", "MMM-yyyy"));
console.log(myFormatDate(date));
}
"MMM-d"
it will not return the year - it will return the date.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question