javascript - Google Apps 脚本 toLocaleDateString 不起作用

标签 javascript google-apps-script google-apps

我尝试在 GAS 脚本中运行

function test(){
var options = { year: 'numeric', month: 'long', day: 'numeric' },
locale="ru-RU",
data= (new Date()).toLocaleDateString(locale, options);

Browser.msgBox(data);
}

但无论我在语言环境中输入什么,谷歌总是返回相同的格式。

如何解决这个问题?

最佳答案

如果您想在服务器端执行此操作,您可以使用 Utilities.formatDate()

var data = Utilities.formatDate(new Date(), "Europe/Moscow", "yyyy-MM-dd");

GAS formatDate() documentation

关于javascript - Google Apps 脚本 toLocaleDateString 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29004599/

相关文章:

javascript - 使用谷歌应用程序脚本检查现有用户

excel - Google Sheets 中的 Google Finance 货币汇率问题

javascript - Require.js 甚至在 IF 语句中加载模块

javascript - Ember 是否支持依赖于其他库的库?

javascript - 获取调用函数的对象

html - Apps 脚本 - 在 HtmlService 中使用来自 Google 云端硬盘的图像

java - 必须先发出 STARTTLS 命令。使用 Java 和 Google Apps 发送电子邮件

google-api - 确定用户是否为组成员

android - Google 的 G Suite 应用程序如何共享数据?

javascript - 将 getElementById() 与 bgcolor 属性一起使用