External JSON DateTime into Collection

I use an external data collector written in C#. I send the data via the WIX POST http-function into a WIX Collection. There are two fields, one is a date field the other is a numeric field.

The external JSON array looks like this:

{
    "dateTime": "2020-12-18T08:00:00Z",
    "mbPercentagePerformance": 40.79
}

The WIX backend function looks like this:

export function post_insertFunctionName(request) {
  let options = {"headers": {"Content-Type": "application/json"}};
  
  // get the request body
  return request.body.text()
    .then( (body) => {
      return wixData.insert("Collection-Name", JSON.parse(body));	  
    } )
    .then( (results) => {options.body = {"inserted": results};
      return created(options);
    } )
    .catch( (error) => {options.body = {"error is": error};
      return serverError(options);
    } );
}

The problem is that the WIX collection can’t handle the ISO 8601 date format I’m passing in with the JSON array. The error in the collection is “The value does not match the field type Date and Time”.

Any help is appreciated!
Thanks

//...
.then(body => {
	let toInsert = JSON.parse(body);
	toInsert.dateTime = new Date(toInsert.dateTime);
      return wixData.insert("Collection-Name", toInsert);	  
    } )
//...

Thanks!
That worked out perfectly.
Is there a reference article showing, how to convert different data types in the backend, before the wixData.insert call?

@affoltes it’s general JavaScript and not Corvid-specific. So I don’t know if you can find an article at Wix, But you can google “js json date” and you’ll find plenty.

I have similar issue with javascript. I am sending new Date() and the format is not accepted. I tried toISOString as well and still shows as wrong format in my data collection. Is there an equivalent solution for javascript?