【问题标题】:Date in phonegap doesn't work correctlyphonegap 中的日期无法正常工作
【发布时间】:2014-04-18 09:08:37
【问题描述】:

当我在我的应用程序和手机日历中保存会议时。在我的申请中,我得到了正常的日期。但是在日历(移动原生)中我发现 dateStart 10h00, dateEnd 10h00, 我应该有 dateStart 09h00, dateEnd 10h00 。

我使用此代码将会议保存在此 github Calendar Plugin 的日历中。

      var startDate = new Date(2014,4,18,9,0,0,0,1);
//The time in console : Fri Apr 18 2014 9:00:00 GMT+0100 (BST)
      var endDate = new Date(2014,4,18,10,0,0,0,1);
      var title = "My nice event";
      var location = "Home";
      var notes = "Some notes about this event.";
      var success = function(message) { alert("Success: " + JSON.stringify(message)); };
      var error = function(message) { alert("Error: " + message); };

   var calOptions = window.plugins.calendar.getCalendarOptions(); // grab the defaults
  calOptions .firstReminderMinutes = 60; // default is 60, pass in null for no reminder (alarm)
  window.plugins.calendar.createEventWithOptions(title,location,notes,startDate,endDate,calOptions,success,error);

【问题讨论】:

  • 虽然我不熟悉电话差距,但这可能与语言环境有关?

标签: javascript android date cordova calendar


【解决方案1】:

在您发布的 sn-p 中,我可以看到您没有 options 变量,而您将其用于:

window.plugins.calendar.createEventWithOptions(title,location,notes,startDate,endDate,options,success,error);

试试这个更新的 sn-p:

     var startDate = new Date(2014,4,18,9,0,0,0,1);
//The time in console : Fri Apr 18 2014 9:00:00 GMT+0100 (BST)
      var endDate = new Date(2014,4,18,10,0,0,0,1);
      var title = "My nice event";
      var location = "Home";
      var notes = "Some notes about this event.";
      var success = function(message) { alert("Success: " + JSON.stringify(message)); };
      var error = function(message) { alert("Error: " + message); };

    var calOptions = window.plugins.calendar.getCalendarOptions(); // grab the defaults
      calOptions.firstReminderMinutes = 120; // default is 60, pass in null for no reminder (alarm)
      window.plugins.calendar.createEventWithOptions(title,location,notes,startDate,endDate,calOptions,success,error);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-07
    相关资源
    最近更新 更多