Extract and parse four parts of a complex date field for use in other fields

My Java knowledge is mostly cut and paste, so hoping for some help.

I want to extract the four parts of a user-entered date field and use them to create 4 distinct values in the same object.

The user enters a complex date that has Start Date, Start Time, End Date, End Time.

In my object, I have fields for each of those four values.

I want to set those fields to the extracted values, but I'm not sure how to parse and extract the different parts of a complex date field. And actually not sure how to set those variables, either. Here's a stab at it, copied and chopped up from another code snippet on complex dates. Any help?

// Update your view number to match your project
$(document).on('knack-record-create.view_259', function(event, view, record) {

var startd, startt, endd, endt data = new Object(); // I think this creates the 4 variables I need.
// Updated my view number, and field numbers field, but now I need to pull each of the 4 parts of the date field out, and not sure how.
var startd = ("#view_259-field_299"), //Parse code goes here, right?
startt = ("#view_259-field_299-time"), //Parse code goes here, right?
endd = ("#view_259-field_299"), //Parse code goes here, right?
endt = ("#view_259-field_299"), //Parse code goes here, right?

Knack.showSpinner();

// This was originally a call that added the complex date to the database. But I need it to add the new simplified dates to the database.
// You will need to update with your own <Application ID> and <API Key>
// Also update with the correct scene and view numbers.
$.ajax({
url: “https://api.knackhq.com/v1/scenes/scene_<204>/views/view_<395>/records/” + record.id ,
type: “PUT”,
headers: {“X-Knack-Application-Id”: “<Application ID>”, “X-Knack-REST-API-Key”:"<API Key>"},
data: data,
success: function(response) {
console.log(“Record Updated with this data:”);
console.dir(data);
},
error: function(response) {
alert(‘Update Failed!’);
console.log( response.error );
},
complete: function () {
Knack.hideSpinner();
}
});
});

I think I'm getting closer, but am getting unexpected values in the JSON.

$(document).on('knack-record-create.view_222', function(event, view, record) {

// use data from inserted record

console.log(record);

var enteredDate = $("#view_222-field_302_raw").val();

var getData = JSON.parse( enteredDate );

alert(getData.date); //output: 02/08/2013
alert(getData.hours); //output: 2
alert(getData.minutes); //output: 0
alert(getData.am_pm); //output: pm

for(i=0;i<getData.to.length;i++)
{
alert(getData[“to”][i].date); //output: 02/11/2013
alert(getData[“to”][i].hours); //output: 2
alert(getData[“to”][i].minutes); //output: 0
alert(getData[“to”][i].am_pm); //output: pm
}
data.field_74 = {
date: Data.date // start date

}

data.field_200 = { // start time
hours: Data.hours, // start hours
minutes: Data.minutes, // start minutes
am_pm: Data.am_pm, // start hours

}

data.field_201 = { // end date
date: Data[to][i].date // start date

}

data.field_134 = { // end time
hours: Data[to][i].hours, // start hours
minutes: Data[to][i].minutes, // start minutes
am_pm: Data[to][i].am_pm, // start am_pm

}

// update the record
$.ajax({
url: “https://api.knackhq.com/v1/objects/object_8/records/” + record.id,
type: “PUT”,
headers: {“X-Knack-Application-Id”: “xxx”, “X-Knack-REST-API-Key”:“xxx”},
data: data,
success: function(response) {

  console.log('Record updated!');
}	

});

});

updated code. This doesn't work yet, but I think I figured out how to parse the date field.

// Update your view number to match your project
$(document).on('knack-record-create.view_259', function(event, view, record) {

var data = new Object();
// Updated my view number, and field numbers field, trying to parse the data object.
var data = ("#view_259-field_299");
var getData = JSON.parse(data);

alert(getData.date); //output: 02/08/2013
alert(getData.hours); //output: 2
alert(getData.minutes); //output: 0
alert(getData.am_pm); //output: pm

for(i=0;i<getData.to.length;i++)
{
alert(getData[“to”][i].date); //output: 02/11/2013
alert(getData[“to”][i].hours); //output: 2
alert(getData[“to”][i].minutes); //output: 0
alert(getData[“to”][i].am_pm); //output: pm
}

Knack.showSpinner();
// This was originally a call that added the complex date to the database. But I need it to add the new simplified dates to the database.
// You will need to update with your own <Application ID> and <API Key>
// Also update with the correct scene and view numbers.
$.ajax({
url: “https://api.knackhq.com/v1/scenes/scene_135/views/view_259/records/” + record.id ,
type: “PUT”,
headers: {“X-Knack-Application-Id”: “<Knack-Application-ID>”, “X-Knack-REST-API-Key”:"<API-Key>"},
field_275 : Data.date,
field_276 : Data.hours":“Data.minutes” “Data.am_pm,
field_277 : Data.to.date,
field_278 : Data.to.hours”:“Data.to.minutes” "Data.to.am_pm,
success: function(response) {
console.log(“Record Updated with this data:”);
console.dir(data);
},
error: function(response) {
alert(‘Update Failed!’);
console.log( response.error );
},
complete: function () {
Knack.hideSpinner();
}
});
});

Javascript. I meant Javascript. Derp.