Hello @Maxim_KM
You may not have the correct version of the driver.js
Take a test with this one:
function convert(x) {
if (x instanceof Date) {
return x.toISOString();
} else if (Array.isArray(x)) {
return x.map(convert);
} else {
return x;
}
}
window.addEventListener("message", async function(event) {
const { origin, data: { key, params } } = event;
let result;
let error;
try {
result = await window.function(...params);
} catch (e) {
result = undefined;
try {
error = e.toString();
} catch (e) {
error = "Exception can't be stringified.";
}
}
const response = { key };
if (result !== undefined) {
result = convert(result);
response.result = { type: "string", value: result };
}
if (error !== undefined) {
response.error = error;
}
event.source.postMessage(response, "*");
});
If you make a new Date with this version of the driver, you will have the date in GMT.
you have to return the date in string format, so yes @gvalero with toLocaleDateString () should also work.
(note that toLocaleFormat is deprecated
Deprecated and obsolete features - JavaScript | MDN)
But if you want to manipulate dates, I encourage you to take this ‘date-Test’ script as a starting point, you don’t have to worry about regional settings or the time difference for the return date-times. .
if you have any questions, i’m getting to know the subject a bit!