Date is off by one day after accessing wjcCore.CollectionView

Posted by: moritz.neugebauer on 13 October 2020, 7:42 pm EST

  • Posted 13 October 2020, 7:42 pm EST

    Dear Wijmo Team,

    I have an issue, where a date is off by one day after I access an item from CollectionView.

    A user enters a date into a cell that is from type date, e.g. 20991226.

    The output is:
    this.flexdata.selectedItems[0].date: Sat Dec 26 2099 00:00:00 GMT+0100 (Mitteleuropäische Normalzeit)

    But when I send the changed item to the server, the date of the item from sourcecollection is:
    "2099-12-25T23:00:00.000Z"


    for (let i = 0; i < this.data.items.length; i++) {
    let tmpItem = this.data.items[i];
    console.log(tmpItem.date);
    if (!tmpItem['id'] && tmpItem['guid']) {
    let convertedItem = Utils.convertFromNative2Katalogwert(tmpItem, this.katalogAttributeMap);
    createdItems.push(convertedItem);
    }
    }

    this.apiService.send(createdItems);


    Is there a place where a transformation happens internally?
  • Marked as Answer

    Replied 14 October 2020, 8:12 pm EST

    Hi Mortiz,

    It seems that when the date is sent to the server, the browser itself is converting the date to the previous date. Even the inbuilt JS methods like toISOString are also converting the dates to the previous day.
    If you can, you may convert the dates to UTC value by using the date.getTime method. It will send the date in milliseconds and you can store it as it in the server. But, you will need to convert the milliseconds back to date before adding them to the flexgrid.

    Regards,
    Ashwin
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels