Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1145
Time within Date column 1 hour ahead
posted

Versioin 14.2.20142.2477

We have a hierarchical grid, one of the parent columns is defined as

dsLastUpdateDate: { key: 'dsLastUpdateDate', headerText: 'Last Update', width: '135px', dataType: "date", format: 'date', formatter: lastUpdateDate }

the key dsLastUpdateDate provides a string based date value in local time.

it is possible to expand rows to reveal child details, one column within the child grid is defined as:

{ key: 'dsLastUpdateDate', headerText: 'Last Update', width: '135px', dataType: "date", format:'date', hidden: false, formatter: lastUpdateDate },

The key dsLastUpdateDate provides a string based date value in local time.

The formatter is shared and defined as 

function lastUpdateDate(value) {
return moment(value).format('L HH:mm:ss');
}

The issue is the child column is displaying an incorrect value, it is display the time plus 1 hour. This corresponds to taking the value provided as UTC and converting to local (which for me is currently UTC+1).

If I change the child column definition to

{ key: 'dsLastUpdateDate', headerText: 'Last Update', width: '135px', dataType: "string", hidden: false, formatter: lastUpdateDate },

the value is displayed correctly.

Any suggestions as to why this would occur. I have ensured that the underlying values provided by the key properties are correct.

Regards

Aidan

Parents
No Data
Reply
  • 15320
    Offline posted

    Hello Aidan,

    In general when a date is created on the client-side it’s created in the local time zone.
    For example, if you create a new date on the client side:
    new Date(“09/09/2015”);
    You’ll see that the created date object will have the timezone offset of your timezone, so for example, if you’re in a timezone with GTM+3:00 that will be reflected in the created date object and you’ll get:
    Wed Sep 09 2015 00:00:00 GMT+0300 (FLE Daylight Time)

    Now, this date will not be same as the one you send from the server, if you’ve send a UTC date (a date without any timezone offsets). To account for that difference, the grid has an enabledUTCDates option( which is false by default), which when enabled will format that client date to UTC ( so for example the date from before will be -3:00 hours to account for the offset of GMT+0300).

    This is where the difference in the date you see comes from. The following topic explains the whole process in more details:
    http://www.igniteui.com/help/using-igniteui-controls-in-different-time-zones

    If you have any further questions, please let me know.

    Regards,

    Tsanna

Children