I am new to salesforce lightning. I have a recordEditForm that I want to submit and before submit I want to make set field TODAY's date from the lightning component controller.I am not able to set the vale and throw error saying
"{"message":"Value for field 'fieldName_Date__c' is not in ISO 8601 format, Value: 1/20/2019 11:19 AM, Runtime class: java.lang.String","detail":"","output":{},"error":{"type":"TRANSPORT_ERROR","details":{}}}"
JavaScript controller
onSubmitofRecordEditForm:function(component, event, helper)
{
var recordEditFormList = component.find("newFormtoUpdate");
// get all fields using event.getParam("fields") and set some field values in the backend onsubmit of the recordEditForm
var eventFields = event.getParam("fields");
var timezone = $A.get("$Locale.timezone");
console.log('Time Zone Preference in Salesforce ORG :'+timezone);// Result::: Time Zone Preference in Salesforce ORG :America/New_York
var mydate = new Date().toLocaleString("en-US", {timeZone: timezone})
console.log('Date Instance with Salesforce Locale timezone : '+mydate);// Result::: Date Instance with Salesforce Locale timezone : 1/20/2019, 11:14:03 AM
var date = mydate.replace(/\,/, '');
var lastModifiedDate = date.replace(/:[0-9]{2}\s/, ' ');
console.log(lastModifiedDate); // Result ::: 1/20/2019 11:14 AM
//salesforce field format is 1/20/2019 11:14 AM
// not able to set the vale and throw error saying
/* {"message":"Value for field 'fieldName_Date__c' is not in ISO 8601 format, Value: 1/20/2019 11:19 AM,
Runtime class: java.lang.String","detail":"","output":{},"error":{"type":"TRANSPORT_ERROR","details":{}}}*/
eventFields["fieldName_Date__c"] = lastModifiedDate;
// global function submit used to submit the recordEditForm
recordEditFormList.submit(eventFields);
}