简体   繁体   English

phonegap中的日期无法正常工作

[英]Date in phonegap doesn't work correctly

When I save a meeting in my application and in calendar of the mobile. 当我在应用程序和手机日历中保存会议时。 In my application, I got the date normally. 在我的申请中,我通常能得到日期。 But in the calendar(mobile Native) I found dateStart 10h00, dateEnd 10h00, I should have dateStart 09h00, dateEnd 10h00 . 但是在日历(移动本机)中,我发现dateStart 10h00,dateEnd 10h00,我应该有dateStart 09h00,dateEnd 10h00。

I used this code to save the meeting in the calendar from this github Calendar Plugin . 我使用此代码从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);

In the snippet you posted I can see you have no options variable and you used it in: 在您发布的代码段中,我可以看到您没有options变量,并且在以下位置使用了它:

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

Try this updated snippet: 尝试以下更新的代码段:

     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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM