here am trying to create/save event in custom SharePoint calendar list using JavaScript,here event is getting created at my entered date but issue with time value means it is not saving my entered time value instead of that it saves some time value which has 5/6 hours difference from my entered time value.
My code is as below.
function bookingRoomForMeeting() {
var ctx = new SP.ClientContext(appWebUrl);//Get the SharePoint Context object based upon the URL
var list = ctx.get_web().get_lists().getByTitle("MyCalendarList"); //Get the List based upon the Title
var listCreationInformation = new SP.ListItemCreationInformation(); //Object for creating Item in the List
listItem = list.addItem(listCreationInformation);
listItem.set_item('Title', $("#txt_Title").val());
var date = $("#txt_startTime").val();
var dateTime = moment(date, 'DD/MM/YYYY HH:mm').format("MM/DD/YYYY HH:mm");
listItem.set_item('EventDate', dateTime);
var enddate = $("#txt_endTime").val();
var enddateTime = moment(enddate, 'DD/MM/YYYY HH:mm').format("MM/DD/YYYY HH:mm");
listItem.set_item('EndDate', enddateTime);
listItem.set_item('EmailId1', $("#txt_EmailId1").val());
listItem.set_item('EmailId2', $("#txt_EmailId2").val());
listItem.update();
ctx.load(listItem);
ctx.executeQueryAsync(
Function.createDelegate(this, success),
Function.createDelegate(this, fail)
);
}
function success() {
alert("Completed");
}
function fail() {
alert("operation failed");
}