# BUG: result as 'date-time' is not returned

**URL:** <https://community.glideapps.com/t/bug-result-as-date-time-is-not-returned/31345>\
**Category:** Ask for Help\
**Tags:** custom-code\
**Created:** [September 3, 2021, 11:19pm UTC](https://community.glideapps.com/t/bug-result-as-date-time-is-not-returned/31345 "2021-09-03T23:19:21Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)\
**Post date:** [September 4, 2021, 3:55am UTC](https://community.glideapps.com/t/bug-result-as-date-time-is-not-returned/31345/4 "2021-09-04T03:55:17Z")

</div>

Hello @Maxim_KM  
You may not have the correct version of the driver.js  
Take a test with this one:

```auto

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](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Errors/Deprecated_toLocaleFormat))

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. .

> [@Date Hell](https://community.glideapps.com/t/date-hell/31031/6):
>
> I share with you the code I made to test the Glide \<-\> JS conversion. There are 2 two scripts: for a Date column for an Array Split (depends on the 1st script) The idea is to come and go and confirm the conversion. Script 1, Date Column Test YC [https://Date-Test.manun2.repl.co](https://Date-Test.manun2.repl.co) Source [https://replit.com/@ManuN2/Date-Test?v=1](https://replit.com/@ManuN2/Date-Test?v=1) Script 2, Array Test YC [https://Date-Test-Array.manun2.repl.co](https://Date-Test-Array.manun2.repl.co) Source : [https://replit.com/@ManuN2/Date-Test-Array?v=1](https://replit.com/@ManuN2/Date-Test-Array?v=1) Please give me a feedb…

if you have any questions, i’m getting to know the subject a bit!

---

_[View the full topic](https://community.glideapps.com/t/bug-result-as-date-time-is-not-returned/31345)._
