javascript - Google Apps Script toLocaleDateString not work - Stack Overflow

I trying to run in GAS scriptfunction test(){var options = { year: 'numeric', month: 'l

I trying to run in GAS script

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

Browser.msgBox(data);
}

But google always return same format no matter what i type in locale.

How to fix this?

I trying to run in GAS script

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

Browser.msgBox(data);
}

But google always return same format no matter what i type in locale.

How to fix this?

Share Improve this question edited Oct 22, 2017 at 9:22 Thomas W 15.4k6 gold badges52 silver badges69 bronze badges asked Mar 12, 2015 at 8:03 Dmitrij HolkinDmitrij Holkin 2,0655 gold badges41 silver badges89 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

If you want to do it server side you can use Utilities.formatDate().

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

GAS formatDate() documentation

Maybe Apps Script doesn't respond to the advanced parameters of toLocaleDateString(). If you are using HTML in your app, I'd try to make the conversion inside a script tag in the HTML, rather than in the server side .gs code.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744905966a4600256.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信