【发布时间】:2020-10-08 00:10:42
【问题描述】:
【问题讨论】:
-
您能否在问题中将您的脚本显示为文本而不是图像?
标签: email google-apps-script google-sheets
【问题讨论】:
标签: email google-apps-script google-sheets
假设headers[0][1] 和headers[0][2] 是Dates,则可以使用toLocaleString() 检索月份名称:
const monthName = headers[0][1].toLocaleString('default', { month: 'long' });
或 GAS 特定的替代方案,使用 formatDate:
const monthName = Utilities.formatDate(headers[0][1], Session.getScriptTimeZone(), "MMMM");
【讨论】:
headers[0][1] 和 headers[0][2] 应该是日期,因为您在它们上使用 getMonth。他们不是吗?如果是这种情况,那么如果您使用我提供的任何替代方案,monthName 是与输入名称相关的月份名称(例如“十月”)。我以为这就是你想要做的,但我不太明白你现在在说什么(例如Headers [0][1] and [0][2] are two cells on a Spreadsheet that have a calendar in them,这是什么意思?)。