【问题标题】:Wrong date format when i create an event in google calendar我在谷歌日历中创建活动时的日期格式错误
【发布时间】:2017-01-05 16:06:57
【问题描述】:

我使用谷歌表单在我的日历中创建活动。我的电子表格上记录的日期格式是欧洲 DD/MM/YYYY,但在创建活动时,谷歌日历将日期信息放在美国格式 MM/DD/YYYY 中。因此,事件在错误的日期显示在我的日历中...

我检查了我的 gsuite 帐户、驱动器、工作表是否设置为正确的语言和时区(法国/巴黎)。 你能帮助我吗 ? 谢谢。

例如。 ZAZOU 先生 3 月 2 日 -----> 2 月 4 日

编辑:我用来创建事件的最后一个代码

function createEvent_ (namedValues) {
  //options are the key/value pairs you can set when created a 
  //calendar event, below accesses the data given for description 
  //and location - guest is hard coded
var options = { description: namedValues.Description[0],
ocation: namedValues.Location[0],
              guests:"exemple"};
  //cEvent makdes the calendar event, You have to choose the calendar 
  //name that you would like to use, then ask for the Name of the event, 
  //start date and end date, then passes the options you have selected above
  var cEvent = CalendarApp.getCalendarsByName("Example")[0].createEvent(
              namedValues.Name[0], 
              new Date(namedValues.Starts), 
              new Date(namedValues.Ends), 
              options)

}

【问题讨论】:

  • 您可以在创建事件时定义时区。来自docs:“如果未指定时区,则在脚本时区的上下文中解释时间值,这可能与日历的时区不同。”发布您的代码也可能会有所帮助。
  • @nehalem 我使用不同的方式来做到这一点,最后我使用来自 chatasweetie link 的代码即使我使用链应用程序制造商 Zappier,结果是一样的......
  • 使用 Zaper ive 也尝试将日期格式化为 MM/DD/YYYY 但它不起作用。
  • 您是否检查过 Google Script 项目中的时区设置?
  • 您能分享一下您用来获取任何活动详情的表格吗?

标签: datetime google-apps-script calendar google-calendar-api google-forms


【解决方案1】:

好的,知道了! 问题来自谷歌表单插件“表单发布者”。我在我的表单中添加了一个额外的日期字段以进行测试。在表单编辑器中,google显示的日期格式是正确的,但是当我探索表单发布者的模板选项时,格式被命名为错误的格式。

【讨论】:

    猜你喜欢
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多