# Weird error in date display

**URL:** <https://forum.wixstudio.com/t/weird-error-in-date-display/3600>\
**Category:** Ask the community\
**Tags:** question, code, wix-stores\
**Created:** [March 21, 2022, 9:43am UTC](https://forum.wixstudio.com/t/weird-error-in-date-display/3600 "2022-03-21T09:43:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![colas-dorothee](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@colas-dorothee](https://forum.wixstudio.com/u/colas-dorothee)\
**Post date:** [March 21, 2022, 9:43am UTC](https://forum.wixstudio.com/t/weird-error-in-date-display/3600/1 "2022-03-21T09:43:26Z")

</div>

Hello everyone,

I have a problem with the display of date stored in database. When it’s displayed in a repeater using a dataset everything works but if I display its by code, nothing goes well : I have a 2h lag and my date goes to the previous day.  
For demo I created a test function backend side which illustrates the problem :

Code :

```javascript
export async function workWithdate(itemId) {
    let dataItem = await wixData.get("Sessions", itemId);
    let date = dataItem.dateDebut;   

    console.log("date : " + date.toLocaleDateString());
    console.log("timezone " + date.getTimezoneOffset());
    console.log("toUTCString() " + date.toUTCString());

    return date;
}

```

Results :

```javascript
[backend/util.js, workWithdate] called with (407f4a72-432a-4cb7-8bc7-5c3b57d73b01)

[backend/util.js, workWithdate] returned with 
Fri Apr 01 2022 00:00:00 GMT+0200 (heure d’été d’Europe centrale)

date : 3/31/2022
timezone 0
toUTCString() Thu, 31 Mar 2022 22:00:00 GMT

```

Results interpretation :  
date return by the function is correct : Fri Apr 01 2022 00:00:00 GMT+0200 (heure d’été d’Europe centrale)  
but when it’s displayed by date.toLocaleDateString() or toUTCString, output is wrong.

Does anyone have tips with that ? It’s really a blocking issue !

---

<div class="post-metadata">

**Author:** ![colas-dorothee](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@colas-dorothee](https://forum.wixstudio.com/u/colas-dorothee)\
**Post date:** [March 22, 2022, 9:42am UTC](https://forum.wixstudio.com/t/weird-error-in-date-display/3600/2 "2022-03-22T09:42:22Z")

</div>

After spending a lot of hours on it, I just realize that :

code : new Date().getTimeZoneOffset()  
return 0 in wix environnement  
return -60 outside off wix  
Correct answers being -60. Maybe a lead ?

After verification, I’m indeed on GMT+1 time zone in the wix’s settings.

---

<div class="post-metadata">

**Author:** ![J.D](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/j.d/32/7312_2.png) [@J.D](https://forum.wixstudio.com/u/J.D)\
**Post date:** [March 22, 2022, 11:03pm UTC](https://forum.wixstudio.com/t/weird-error-in-date-display/3600/3 "2022-03-22T23:03:24Z")

</div>

You now that if you run it on the backed it uses the server locales. Right?

---

<div class="post-metadata">

**Author:** ![colas-dorothee](https://avatars.discourse-cdn.com/v4/letter/c/f6c823/32.png) [@colas-dorothee](https://forum.wixstudio.com/u/colas-dorothee)\
**Post date:** [March 23, 2022, 5:46am UTC](https://forum.wixstudio.com/t/weird-error-in-date-display/3600/4 "2022-03-23T05:46:19Z")

</div>

Thanks JD for your answer.  
No I didn’t know but I just realize yesterday that the behavior what different front side indeed.  
I finally came with a solution using Intl.DateTimeFormat but it has really been struggling time !!!
