Date & Time Field Type Issue With Editor X

I have an afterInsert() hook on Site A which makes a fetch call to Site B 's endpoint.

The endpoint on Site B inserts the received body into a collection. The issue is that both on Site A & Site B there is a “Date & Time” field type but the value is never inserted properly on Site B. It always prompts to “Convert” and if not manually converted the date appears weird on the live site (Screenshots below).

Additional info: Site A is a normal Wix Site & Site B is Editor X

@Shan could you share the piece of code where you save the data?
I imagine data come in as JSON, but Wix has its own way of formatting dates

"date": { "$date": "<myStringifiedDate>"  }

So I believe the easiest way is to convert the date field from JSON to Date and let the data API save the data

Or

translate each JSON Date field into a Wix Date Field

I think it may be a conversion of the type Date to String when you fetching it.

Try to wrap the data string to new Date

// Your hook goes here

const response = await getJSON(apiUrl);

return {
   ...response,
   expiryDefault: new Date(response.expiryDefault),
};

Shouldn’t that be:

expiryDefault: new Date(response.expiryDefault),

Yup you’re right, converting it to js date object works

Thank you. Works now.