在Google Script中从.getValue欢迎时更改日期"格式"

use*_*913 2 google-sheets google-apps-script

所以,我知道你使用类似东西时得到的日期对象

`var ADateFrommyspreadsheet = Sheet.getRange('J1').getValue();
Run Code Online (Sandbox Code Playgroud)

没有"格式",但当我使用该值来替换文档中的文本时:

`copyBody.replaceText('keyTodaysDate', TodaysDate); 
Run Code Online (Sandbox Code Playgroud)

它的工作取代了2013年7月3日星期三00:00:00 GMT-0400(EDT)的文本我只是想要阅读2013年7月3日星期三,或2013年7月3日或其他一些"格式".预先感谢您的任何帮助!

Ada*_*amL 6

您可以使用"实用程序"服务返回根据需要格式化的日期.

var TodaysDate = Utilities.formatDate(ADateFrommySpreadsheet, "GMT", ""EEE MMM dd yyyy");
Run Code Online (Sandbox Code Playgroud)

https://developers.google.com/apps-script/reference/utilities/utilities#formatDate(Date,String,String)