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
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
Hi
Thanks for the response.
I am familiar with handling different timezones and the differences between UTC and local etc.
We are handling our UTC <-> local Display Time logic ourselves, basically anything transmitted or stored is UTC, anything going to display is converted to user's local time.
The values given to the parent column and child column are both correct and in some scenarios exactly the same value. The parent column displays it correctly, the child column does not, unless I change the column definition to have a datatype of string.
The question is why is the child column behaving differently when
a. it has the same column definition as the parent, i.e datatype:"date", format="date"
b. it is being given the same value to display.
We have not set enableUTCDates explicitly, since the default of false is what we want.