Inserting a date into a CMS collection field depends on the field data type and options.
It’s important to check whether “Include time field” is selected as it will affect how you need to insert data into your CMS collection.
If you have a “Date” Field without “Include time field” selected, the string that is written to the collection must be in ISO 8601 format without the time.
Example
let dateObject = new Date();
let toInsert = {
"_id": "00001",
"title": "Item 01",
"date": dateObject.toISOString().substring(0, 10)
};
If you have a “Date” Field with “Include time field” selected, the string must be written to the collection using a JavaScript Date Object.
Example
let dateObject = new Date();
let toInsert = {
"_id": "00001",
"title": "Item 01",
"date": dateObject
};
For more information check out the documentation below: