【发布时间】:2013-04-11 16:19:25
【问题描述】:
function onFormSubmit(e) {
var d = e.values[1] + " 10:00:00 UTC";
var start = new Date(d);
// oncatenating the string as above fails?
// ... form then sends an email and adds date to a Google Calendar
我正在使用 Google 电子表格存储从该电子表格生成的 Google 表单的开始、结束、标题值。我现在想将这些值添加到 Google 日历中。
问题是,如果我使用串联来构造字符串(因此输入可以接受 2013 年 4 月 4 日),日期将失败,当我通过电子邮件向自己发送值时“日期无效”。
也许这很奇怪,但是带有调试的电子邮件还带有前面的 ' 好像它正在转义值或其他东西......
var emailBody = "Booking enquiry was made on " + timestamp +
"\n\nThe details they entered were as follows: " +
"\nFrom: " + start + " vs original date input : " + e.values[1] +
// etc
提供: 预订查询于 11/04/2013 17:53:06 进行
他们输入的详细信息如下: 来自:无效日期与原始日期输入:'04/03/2013
看到了吗? '04/03/2013
更新
Serge insas 的回复有效,但后来我发现 ' 仅在 Google 表单托管在我的本地主机开发服务器上时才会出现。当页面上线时(包含 iFrame),则不需要子字符串删除技巧,因为前面没有 '。
【问题讨论】:
标签: date google-apps-script google-calendar-api